Configure Individual Bitrates in FFmpeg Tee Muxer

This article explains how to configure individual video bitrates for different outputs when using the FFmpeg tee muxer. While the tee muxer is typically used to split a single encoded stream to multiple destinations without re-encoding, you can achieve different bitrates for each output by encoding multiple stream variants simultaneously and using the select option to route them.

The Limitation of the Tee Muxer

By default, the tee muxer copies identical packets to all specified outputs. It cannot dynamically re-encode or change the bitrate of a single stream for different destinations. To output different bitrates, you must perform multiple encodings inside the same FFmpeg command and then map each encoded stream to its respective output.

The Solution: Multi-Map and Select

To send different bitrates to different outputs, follow these steps: 1. Map the input stream multiple times. 2. Define different encoder settings (bitrates) for each mapped stream. 3. Use the select option within the tee muxer payload to assign specific video and audio streams to specific outputs.

Example FFmpeg Command

Here is a practical command that takes an input file, encodes it into two different bitrates (4000k and 1500k), and outputs them to two different destinations using the tee muxer:

ffmpeg -i input.mp4 \
  -map 0:v -map 0:v -map 0:a \
  -c:v:0 libx264 -b:v:0 4000k \
  -c:v:1 libx264 -b:v:1 1500k \
  -c:a aac -b:a 128k \
  -f tee "[select=\'v:0,a:0\']high_bitrate.mp4|[select=\'v:1,a:0\']low_bitrate.mp4"

Command Breakdown

Note: Depending on your command-line shell (such as Bash, zsh, or Windows CMD), you may need to adjust the escaping of the single quotes (\' or ') around the select filters.