Why Audio Routing Matters

In professional broadcast, audio is not a single stereo pair. A production feed might carry 8, 16, or more audio channels: program audio in multiple languages, a clean international sound mix, commentary tracks, ambient microphones, and talkback channels. Getting the right audio channels to the right outputs is just as critical as routing the video.

Vajra Cast includes a built-in audio matrix router that operates at the channel level. You can map any input audio channel to any output audio channel, mix channels, and configure different audio layouts for different outputs, all without touching the video.

Audio Matrix Concepts

Channels vs. Tracks

Audio in a transport stream is organized into tracks (also called PIDs or elementary streams), and each track contains one or more channels:

  • Track: A distinct audio elementary stream. A transport stream can carry multiple tracks (e.g., track 1 = English, track 2 = Spanish).
  • Channel: An individual audio signal within a track. A stereo track has 2 channels (left, right). A 5.1 surround track has 6 channels.

Vajra Cast’s audio matrix operates at the channel level, giving you the finest-grained control possible. You can route individual channels from any input track to any output track.

The Matrix

Think of the audio matrix as a grid. Rows are input channels, columns are output channels:

              Output Ch1  Output Ch2  Output Ch3  Output Ch4
Input Ch1        X
Input Ch2                    X
Input Ch3                                 X
Input Ch4                                              X
Input Ch5        X                        X
Input Ch6                    X                         X

An “X” means the input channel is routed to that output channel. If multiple inputs are routed to the same output, they are mixed (summed). If no input is routed to an output, that output channel is silent.

This matrix is configured per output. Different outputs on the same route can have completely different audio mappings.

Common Use Cases

Multi-Language Distribution

A common broadcast scenario: the production feed carries English commentary on channels 1-2 and Spanish commentary on channels 3-4. You need to distribute to two CDNs, each receiving only one language.

English CDN output:

Input ChannelOutput Channel
Ch 1 (English L)Ch 1 (Stereo L)
Ch 2 (English R)Ch 2 (Stereo R)

Spanish CDN output:

Input ChannelOutput Channel
Ch 3 (Spanish L)Ch 1 (Stereo L)
Ch 4 (Spanish R)Ch 2 (Stereo R)

Both outputs receive the same video. Only the audio mapping differs. This is configured entirely in the audio matrix. No transcoding required for the audio remapping.

International Sound + Commentary

Sports broadcasts typically carry an “international sound” mix (crowd noise, on-field audio) that is language-neutral, plus separate commentary tracks. The final output for each region combines the international sound with the local commentary.

Input channels:

  • Ch 1-2: International sound (stereo)
  • Ch 3-4: English commentary (stereo)
  • Ch 5-6: French commentary (stereo)

English output matrix (mix international + English):

InputOutput Ch 1Output Ch 2
Ch 1 (Intl L)X
Ch 2 (Intl R)X
Ch 3 (Eng L)X
Ch 4 (Eng R)X

The output receives international sound mixed with English commentary on a stereo pair. The French output would map channels 5-6 instead of 3-4.

Mono to Stereo / Stereo to Mono

Some encoders send mono audio. Some outputs require stereo. The audio matrix handles this:

Mono to stereo (duplicate):

InputOutput Ch 1Output Ch 2
Ch 1XX

Stereo to mono (mix down):

InputOutput Ch 1
Ch 1X
Ch 2X

When both channels are routed to a single output channel, they are summed. You get a proper mono downmix.

Channel Swapping

Sometimes the left and right channels arrive swapped from the source. Fix it in the matrix without re-encoding:

InputOutput Ch 1Output Ch 2
Ch 1 (was L, actually R)X
Ch 2 (was R, actually L)X

Audio-Follow-Video

In multi-input failover configurations, audio routing interacts with video failover. When the active video input switches from primary to backup, the audio should follow. You want the audio from the same source as the video.

Vajra Cast handles this automatically. The audio matrix configuration is defined per input, and when failover switches the active input, the audio matrix switches with it. This ensures:

  • The output always receives audio from the same source as the video.
  • There is no audio/video mismatch during or after a failover switch.
  • Each input can have its own channel mapping, accounting for differences in audio layout between encoders.

Per-Input Audio Mapping

If your primary encoder sends 8-channel audio (English on 1-2, Spanish on 3-4, international on 5-6, talkback on 7-8) but your backup encoder sends only 4 channels (English on 1-2, international on 3-4), you can define different matrices for each input:

Primary input matrix (for English CDN):

Input ChOutput Ch
1 (Eng L)1
2 (Eng R)2

Backup input matrix (for English CDN):

Input ChOutput Ch
1 (Eng L)1
2 (Eng R)2

Same output, different source channels. When failover switches from primary to backup, the English CDN output continues receiving English audio, even though it comes from different channel positions on the backup encoder.

Configuration

Audio matrix routing is configured through the Vajra Cast web interface or the REST API.

Via the Web Interface

  1. Navigate to your route.
  2. Select an output.
  3. Open the “Audio” tab.
  4. The matrix grid appears, showing all available input channels and output channels.
  5. Click cells to create or remove mappings.
  6. Changes apply immediately. No stream interruption.

Via the REST API

curl -X PUT -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "audioMatrix": [
      {"inputChannel": 1, "outputChannel": 1},
      {"inputChannel": 2, "outputChannel": 2},
      {"inputChannel": 5, "outputChannel": 3},
      {"inputChannel": 6, "outputChannel": 4}
    ]
  }' \
  http://localhost:8080/api/v1/routes/1/outputs/1/audio

This maps input channels 1-2 to output channels 1-2 and input channels 5-6 to output channels 3-4.

Technical Details

Sample-Accurate Mixing

When multiple input channels are routed to the same output channel, Vajra Cast performs sample-accurate mixing. The audio samples are summed and normalized to prevent clipping. This happens in real-time with minimal CPU overhead.

Supported Formats

The audio matrix operates on decoded PCM audio, so it works regardless of the input or output audio codec:

  • Input codecs: AAC, MP2, AC-3, Opus
  • Output codecs: AAC, MP2, AC-3, Opus

The matrix routing is applied between the decode and encode stages of the audio pipeline.

Channel Limits

Vajra Cast supports up to 16 input channels and 16 output channels per route. This covers the vast majority of broadcast workflows, including 5.1 and 7.1 surround configurations with multiple language tracks.

Next Steps