Target Mapping
This tutorial explains how you can use target audio mapping to control which source audio tracks and channels are directed to the audio components in your output files.
Usage
When you define your source
at the start of a job, the option is available to map
the source audio in the contents
array into some configuration that would be passed down directly through the “virtual” source_pipeline
to your target output.
But there may be an occasion when you need the audio to be configured in more than one way for different targets
in the same transcode
task. This is where target audio mapping would be used.
Example
Let’s say your source
has one audio track - a stereo pair - and you want to produce two output files with different audio configurations:
- the first with 1 track/2 channels (target_A_2-channel.mov)
- the second with 2 tracks/1 channel each (target_B_2-track.mov)
By using audio mapping in the target
of your transcode
task as shown below (see the source
arrays in each audio object), you can direct the desired source audio to each target audio component.
{
"targets": [
{
"file_pattern": "target_A_2-channel.mov",
"existing_files": "replace",
"container": {
"kind": "mov"
},
"audio": [
{
"codec": "pcm",
"channels": 2,
"source": [
{
"track": 0,
"channel": 0
},
{
"track": 0,
"channel": 1
}
]
}
]
},
{
"file_pattern": "target_B_2-track.mov",
"existing_files": "replace",
"container": {
"kind": "mov"
},
"audio": [
{
"codec": "pcm",
"channels": 1,
"source": [
{
"track": 0,
"channel": 0
}
]
},
{
"codec": "pcm",
"channels": 1,
"source": [
{
"track": 0,
"channel": 1
}
]
}
]
}
]
}
This diagram illustrates the effect of using target mapping from the example code above:
Another Example
There may also be a situation when you need to produce multiple outputs, with each one receiving audio from specific source audio tracks. Let’s say your source contains two audio tracks: a 6-channel surround group in track 0, and a 2-channel stereo pair in track 1. Suppose you need to produce two separate MOV outputs: the first with just the stereo audio, and the second with two audio tracks; the first track with the stereo, and the second track with the surround. The code example below shows how this would be accomplished.
Note: when an entire track from the source is to be used in a target audio track, mapping of the individual channels is not required. Mapping only the tracks is sufficient.
{
"targets": [
{
"file_pattern": "target_C_2-channel.mov",
"existing_files": "replace",
"container": {
"kind": "mov"
},
"audio": [
{
"codec": "pcm",
"channels": 2,
"source": [
{
"track": 1
}
]
}
]
},
{
"file_pattern": "target_D_2-channel.mov",
"existing_files": "replace",
"container": {
"kind": "mov"
},
"audio": [
{
"codec": "pcm",
"channels": 2,
"source": [
{
"track": 1
}
]
},
{
"codec": "pcm",
"channels": 6,
"source": [
{
"track": 0
}
]
}
]
}
]
}