Skip to main content

Audio filtering example

Packager can filter the audio pipeline to extract channels and build new tracks from them. For example, it can split an 8-channel audio feed from SDI into 4 stereo tracks.

Filter config​

Add filters to a transcoding configuration, like below (see https://ffmpeg.org/ffmpeg-filters.html#channelmap for documentation on filtering):

toml
[[transcoders.tracks]]
type = "audio"
id = "audio"

[transcoders.tracks.processing]
filters = "channelmap=map=0"

This configuration selects channel index 0, the first channel of the input audio, and makes it the only channel of the output: a mono track with only the left channel. Channel indices start at 0.

A more complex configuration that extracts a stereo track from indices 4 and 5, the fifth and sixth channels of an 8-channel audio track, could look like this:

toml
filters = "channelmap=map=4|5"

Or by explicitly specifying the output index as well:

toml
filters = "channelmap=map=4-0|5-1"

Filter config - full example​

This example applies audio filtering to an SDI source and publishes the encoded result to Vindral Live using the vindral_ws WebSocket sink.

Set the DeckLink device name and channel mapping for your SDI signal. Replace YOUR_VINDRAL_PUBLISH_URL with your channel's publish URL, https://lb.cdn.vindral.com/api/edge/publish-url/YOUR_STREAM_KEY.

Download audio-filtering.toml.

toml
# Vindral Bridge Packager example
# SDI capture to Vindral Live, with a channelmap filter that keeps audio channel indices 4 and 5 (the fifth and sixth channels).

version = "3"

[[sources]]
id = "sdi"
source_type = "decklink_sdk"

[sources.protocol_options.device]
type = "string"
value = "DeckLink Duo (1)" # first port

# Keep video flowing through signal loss so the publisher is not dropped.
[sources.demuxer_options.signal_loss_action]
type = "string"
value = "black_frame"

# 32-bit PCM keeps the card's 24-bit samples.
[sources.demuxer_options.audio_depth]
type = "u_int"
value = 32

# The channelmap filters below read channel indices 4 and 5 (the fifth and sixth channels), so capture all eight.
[sources.demuxer_options.channels]
type = "u_int"
value = 8

[[sinks]]
id = "vindral"
sink_type = "vindral_ws"
source_ids = ["encode"]

[sinks.protocol_options.url]
type = "string"
value = "YOUR_VINDRAL_PUBLISH_URL"

[[transcoders]]
id = "encode"
source_ids = ["sdi"]

[[transcoders.tracks]]
id = "video"
type = "video"

[transcoders.tracks.track_selector]
type = "track-kind"
kind = "video"

[[transcoders.tracks.renditions]]
id = "720p"
codec = "h264"
gop_size_ms = 1000
bit_rate = 3_000_000
max_b_frames = 0

[transcoders.tracks.renditions.size]
width = 1280
height = 720

[[transcoders.tracks.renditions]]
id = "jpeg-1280"
codec = "mjpeg"
gop_size_ms = 2000
bit_rate = 1280
frame_skipping = "frame_every_5_seconds"

[transcoders.tracks.renditions.size]
width = 1280

[[transcoders.tracks]]
id = "audio"
type = "audio"

[transcoders.tracks.track_selector]
type = "track-kind"
kind = "audio"

[transcoders.tracks.processing]
filters = "channelmap=map=4|5"

[[transcoders.tracks.renditions]]
id = "aac"
codec = "aac"
sample_rate = 48_000
channels = 2
bit_rate = 128_000

[[transcoders.tracks.renditions]]
id = "opus"
codec = "opus"
sample_rate = 48_000
channels = 2
bit_rate = 128_000