Audio Mapping Tutorial
When working with video, you often deal with sources coming from a variety of providers who have different standards. One of the most common problems is dealing with audio that is not correctly organized for your targeted output. This tutorial will show you how to re-map audio so that it meets your requirements.
Tracks and Channels
A media file can have multiple tracks of audio, and each track can have 1 or more channels. For example, a file might have 2 tracks of audio – one for English and one for Spanish. Both of these tracks could be stereo (2 channels), or they might both be surround (6 channels), or one of them might be stereo and the other surround. There are an enormous number of variations in how audio gets mastered, archived, and distributed throughout the video world, and every workflow can adopt a different standard. Another example might be two surround sound mixes. One company may store that as 12 discrete tracks (1 channel each), while another may store it as 2 tracks (6 channels each).
The “Map” Function
The purpose of the map
function is to allow you to treat audio tracks differently from how they are in the source media. Let’s take a simple example, where you have a source file that has two discrete mono audio tracks. But, on the output side, you actually want stereo. You can use the “map” function to tell Hybrik to re-map the audio and act as if the original media was actually stereo in the first place. Remember that tracks and channels are arrays, so the first track would be track 0
. Here is an example mapping function that maps two separate audio tracks into a single stereo track
"map": [
{
"input": {
"track": 0,
"channel": 0
},
"output": {
"track": 0,
"channel": 0
}
},
{
"input": {
"track": 1,
"channel": 0
},
"output": {
"track": 0,
"channel": 1
}
}
]
We can use that map
object in our source description as follows:
{
"uid": "source_file",
"kind": "source",
"payload": {
"kind": "asset_url",
"payload": {
"storage_provider": "s3",
"url": "s3://path/to/my_file.mxf",
"contents": [
{
"kind": "video"
},
{
"kind": "audio",
"map": [
{
"input": {
"track": 0,
"channel": 0
},
"output": {
"track": 0,
"channel": 0
}
},
{
"input": {
"track": 1,
"channel": 0
},
"output": {
"track": 0,
"channel": 1
}
}
]
}
]
}
}
}
Audio mapping on the source is very powerful, in that it lets you pretend that the original source is something completely different than what it really is. You can remap, remix, or ignore tracks and channels to get the desired result. If you map two (or more) channels to the same output channel, Hybrik will perform a mix down on the combined audio tracks. Also, if you include a remapping of some channels but not others then Hybrik will ignore those unmapped channels.
Automatic Remapping
In many scenarios, Hybrik will automatically remap the audio in order to achieve the desired output. For example, if you give Hybrik a surround source and tell it to create a stereo output, Hybrik will automatically create a stereo downmix of the source. There is no need to explicitly create this in your JSON. Additionally, Hybrik will automatically match source and target audio tracks. So, if you have a stereo track and a surround track (in that order) in your source, and you have a stereo and surround track on the output, then Hybrik will automatically map those tracks correctly. If, however, you wanted the stereo mapped to the surround output and the surround mapped to the stereo output then you would need to do remapping.
Selecting Tracks on the Target
In the above examples, we were re-mapping the source audio. There are also cases where you want to select only specific source tracks or channels be used in the output. One example of this is where a client has two tracks of incoming stereo audio – one for Spanish and one for English. But, the file that is being created is a proxy file used for testing dubbing. In that case, the proxy actually has a single track of stereo audio with the English on the left side and the Spanish on the right side. This is done because it is easy to change the balance while listening to the translation and verify its correctness. So, the client needs to tell Hybrik to take the left side from the English track and the right side from the Spanish track. This is done by specifying a source
parameter for the audio in the target. Here’s how that would look
"audio": [
{
"codec": "aac",
"channels": 2,
"sample_rate": 48000,
"sample_size": 16,
"bitrate_kb": 128,
"bitrate_mode": "vbr",
"source": [
{
"track": 0,
"channel": 0
},
{
"track": 1,
"channel": 0
}
]
}
]
Audio Mapping Examples
Here is an example that takes an input source with two tracks of audio and re-maps them so that they swap places – e.g. track 0
becomes track 1
and vice versa
- Multiple Audio Sources Remap example
- Audio Swap Tracks Remap example
- Source Interleaved to Discrete Mapping Example