Audio Mapping Guide

This topic explains audio mapping options for multiple audio tracks.

Introduction

It is common for editing systems to output video files that contain multiple audio tracks - either for surround sound audio, archival, or multi-language scenarios. Using Zencoder, input files that contain multiple audio tracks can be mapped or mixed down to a single audio track on the output. For example, these options can be combined to map 6 discrete mono PCM audio tracks from an input file into a single 5.1 surround sound audio track on an output.

This guide introduces two options: input_audio_channels and output_audio_channels, which can be used to control how audio tracks and channels from an input file are mapped into the output file.

Supported input audio channels

The following audio channels are supported for import:

  • FL
  • FR
  • FC
  • LFE
  • BL
  • BR
  • Lt (FL matrix)
  • Rt (FR matrix)

Create multiple outputs from a source with multiple audio tracks

A fairly common use case is to have a source video with multiple audio tracks, and you want to output multiple audio files, each having one of the audio tracks. Here is the best way to configure the outputs for this:

outputs: [
  {
  label: "Output 1",
  url: "your hosting server for outputs/output1.mp4",
  skip_video: true,
  "input_audio_service_types":{"1": "main"},
  "select_audio_service_type": "main"
  },
  {
  label: "Output 2",
  url: "your hosting server for outputs/output2.mp4",
  skip_video: true,
  "input_audio_service_types":{"2": "main"},
  "select_audio_service_type": "main"
  },
  {
  label: "Output 3",
  url: "your hosting server for outputs/output3.mp4",
  skip_video: true,
  "input_audio_service_types":{"3": "main"},
  "select_audio_service_type": "main"
  } ... 

Audio mapping options

The input_audio_channels option can be used to tag individual audio tracks or channels from the input file by giving them a channel name, like FL for the "front-left" channel in a 5.1 surround audio track. The examples below demonstrate how to use this option to map from 6 individual audio tracks to a single 5.1 surround track.

By setting the output_audio_channels option, the output audio track's channel layout can be customized. If this is not set, then the default arrangement for the audio codec is used.

The output_audio_channels option can be used in two ways: to create a mixdown of all of the channels in input_audio_channels, or to create an output with audio channels remapped to a custom output channel layout without performing any mixing. Zencoder can generate a stereo or mono mixdown from a multi-channel or surround sound input audio track. To create a mixdown output, set this option to either 1 (for mono) or 2 (for stereo). To create a custom channel layout, set this option to an array of track identifiers which were defined in the input_audio_channels option. See the examples below for more information.

Zencoder currently supports mono, stereo, and 5.1 channel output audio.

Stereo mixdowns can be generated from surround sound audio by using both the input_audio_channels and output_audio_channels options. By setting output_audio_channels to 2, it is possible to create a stereo mixdown.

Example Settings

5.1 Surround Track from Multiple Mono Tracks

This example maps individual audio tracks into the named channels FL, FR, FC, LFE, BL, BR and create a single 5.1 surround sound track from the mapping.

{
  "input": "s3://zencodertesting/test-multitrack-audio.mov",
  "output": {
    "input_audio_channels": {
      "FL": 1,
      "FR": 2,
      "FC": 3,
      "LFE": 4,
      "BL": 5,
      "BR": 6
    }
  }
}

Stereo Mixdown from a Mapped 5.1 Surround Track

The example below shows how to create a stereo mixdown from the 5.1 surround audio track that was created in the example above.

{
  "input": "s3://zencodertesting/test-multitrack-audio.mov",
  "output": {
    "input_audio_channels": {
      "FL": 1,
      "FR": 2,
      "FC": 3,
      "LFE": 4,
      "BL": 5,
      "BR": 6
    },
    "output_audio_channels": 2
  }
}

Custom Audio Channel Layout

The output_audio_channels option can be used to create a custom channel layout in addition to creating mixdowns. The example below will create a stereo output from the front-left and front-right channels, but with their order swapped, so the left channel is in the right and vice versa.

{
  "input": "s3://zencodertesting/test-multitrack-audio.mov",
  "output": {
    "input_audio_channels": {
      "FL": 1,
      "FR": 2,
      "FC": 3,
      "LFE": 4,
      "BL": 5,
      "BR": 6
    },
    "output_audio_channels": ["FR", "FL"]
  }
}

Supporting Multiple Language Tracks

By using the input_audio_channels option on an input that contains multiple language tracks, it is possible to create multiple outputs each with separate language tracks. Assume that an input file had 4 discrete audio tracks and that track 1 contained the English (left) audio, track 2 contained the English (right) audio, track 3 contained the Spanish (left) audio and track 4 contained the Spanish (right) audio. By defining the input_audio_channels parameter differently for each output, it is possible to create multiple language outputs from a single file.

{
  "input": "s3://zencodertesting/test-multitrack-audio.mov",
  "outputs": [
    {
      "label": "english",
      "input_audio_channels": {
        "FL": 1,
        "FR": 2
      }
    },
    {
      "label": "spanish",
      "input_audio_channels": {
        "FL": 3,
        "FR": 4
      }
    }
  ]
}

Custom Channel Mapping

The example below shows how to extract an existing stereo downmix out of a media file, in which the first audio track contains both a 5.1 surround mix and a stereo downmix (where stereo pair).

{
  "input": "s3://zencodertesting/test-multichannel-audio.mov",
  "output": {
    "input_audio_channels": {
      "FL": "1:7",
      "FR": "1:8"
    },
    "output_audio_channels": 2
  }
}

Another use case is a source file with 8 audio tracks and each track has 1 channel. In this case, you will need to use mapping such as the one below:

{
  "input": "s3://zencodertesting/test-multichannel-audio.mov",
  "output": {
    "input_audio_channels": {
      "FL": "7:1",
      "FR": "8:1"
    },
    "output_audio_channels": 2
  }
}