Name Audio Streams in FFmpeg Filtergraphs
Managing multiple audio tracks in FFmpeg can quickly become complicated. This guide explains how to assign custom names (labels) to audio stream links inside FFmpeg filtergraphs, making it easy to route, process, and map specific audio outputs to your final destination file.
Understanding Link Labels
In FFmpeg, custom names for streams inside a filtergraph are called
link labels. They are defined using square brackets
([label_name]).
Link labels act as variables: they tag the output of one filter so you can pass it as an input to another filter, or map it directly to the output file.
Basic Syntax
To name a stream, place your desired custom name in square brackets immediately after a filter definition.
[input_stream] filter_name=arguments [custom_link_name]For example, to take the first input file’s audio (0:a),
increase its volume, and name the resulting stream
[boosted_audio]:
-filter_complex "[0:a] volume=1.5 [boosted_audio]"A Practical Multi-Stream Example
Link labels are incredibly useful when splitting an audio stream to apply different filters to each path.
In the command below, we split a single audio input into two streams, apply a highpass filter to one, a lowpass filter to the other, name them custom identifiers, and map them both to the final output file:
ffmpeg -i input.mp4 -filter_complex \
"[0:a] asplit=2 [to_high][to_low]; \
[to_high] highpass=f=500 [high_filtered]; \
[to_low] lowpass=f=500 [low_filtered]" \
-map 0:v \
-map "[high_filtered]" \
-map "[low_filtered]" \
output.mkvHow this works:
[0:a] asplit=2 [to_high][to_low]: Takes the primary audio stream (0:a) and splits it into two identical streams, naming them[to_high]and[to_low].[to_high] highpass=f=500 [high_filtered]: Takes the[to_high]stream, applies a highpass filter, and outputs it as a new custom stream named[high_filtered].[to_low] lowpass=f=500 [low_filtered]: Takes the[to_low]stream, applies a lowpass filter, and outputs it as[low_filtered].-map "[high_filtered]"and-map "[low_filtered]": Instructs FFmpeg to include these specifically named streams as individual audio tracks in the finaloutput.mkvfile.
Rules for Naming Link Labels
When choosing custom names for your audio streams, keep the following
rules in mind: * Allowed Characters: Use alphanumeric
characters (a-z, A-Z, 0-9) and underscores (_). Avoid
spaces and special characters. * Uniqueness: Each
output link label must be unique within the filtergraph. You cannot
write two different filters that output to the same label name. *
Consumability: Once an output label is used as an input
for another filter, it is “consumed” and cannot be reused elsewhere
unless you split it again using the asplit filter.