Configure FFmpeg Tee Muxer Select Maps

This article explains how to configure individual stream select maps for different outputs when using the FFmpeg tee muxer. You will learn the correct syntax, escaping rules, and practical examples to split, filter, and route specific audio, video, or subtitle streams to different destination files or streams in a single command execution.

Understanding the Tee Muxer Select Syntax

The tee muxer allows you to output the same encoding process to multiple destinations. To customize which streams go to which output, you must use the select option within the output-specific option list, enclosed in square brackets [] before the output path.

The basic syntax for applying a stream select map inside the tee muxer is:

-f tee "[f=format:select='stream_specifiers']output1|[f=format:select='stream_specifiers']output2"

Stream Specifiers

The select option uses standard FFmpeg stream specifiers: * v - Selects all video streams. * a - Selects all audio streams. * s - Selects all subtitle streams. * v:0 - Selects the first video stream. * a:1 - Selects the second audio stream. * 0 or 1 - Selects streams by their absolute input/mapping index.

Escaping Characters (Crucial step)

Because the tee muxer parses options using a specific delimiter system, you must escape the single quotes around the select values, as well as any commas used to separate multiple stream specifiers.

In most shells, single quotes inside the bracketed options must be escaped as \'.

Practical Examples

Example 1: Splitting Audio Tracks to Different Files

If you have an input file with one video track and two different language audio tracks, you can write two separate files: one containing the first audio track, and one containing the second.

ffmpeg -i input.mkv -map 0:v -map 0:a -c copy -f tee \
"[f=mp4:select=\'v,a:0\']english_output.mp4|[f=mp4:select=\'v,a:1\']spanish_output.mp4"

In this command: * -map 0:v -map 0:a maps all video and audio streams from the input. * select=\'v,a:0\' filters the first output to only include the video and the first audio stream. * select=\'v,a:1\' filters the second output to only include the video and the second audio stream.

Example 2: Saving Video to One File and Audio to Another

To completely separate the video and audio streams into individual containers using a single pass:

ffmpeg -i input.mp4 -map 0:v -map 0:a -c copy -f tee \
"[f=mp4:select=\'v\']only_video.mp4|[f=mp3:select=\'a\']only_audio.mp3"

Example 3: Multiplexing Selects with Commas

To select multiple specific streams (e.g., the first video stream and the second audio stream only, skipping the first audio stream), separate the specifiers with a comma inside the escaped quotes:

ffmpeg -i input.mkv -map 0:v -map 0:a -c copy -f tee \
"[f=matroska:select=\'v:0,a:1\']isolated_output.mkv"