Configure SRT Stream Multiplexing in FFmpeg

This article provides a practical guide on how to configure Secure Reliable Transport (SRT) stream multiplexing using FFmpeg. You will learn how to combine multiple video, audio, and metadata streams into a single SRT container, configure the necessary MPEG-TS muxer settings, and execute precise FFmpeg commands for low-latency, multi-stream broadcasting.

Understanding SRT and Multiplexing

SRT is a latency-optimized streaming protocol that natively wraps media inside an MPEG Transport Stream (MPEG-TS) container. To multiplex (mux) multiple streams—such as one video track and multiple language audio tracks—into a single SRT broadcast, you must configure FFmpeg to map these streams correctly into an MPEG-TS format before sending them over the SRT protocol.


Step-by-Step Configuration

1. Map Your Input Streams

To multiplex multiple inputs, use the -map option in FFmpeg. This tells FFmpeg exactly which video and audio streams to include in the output multiplex.

2. Set the MPEG-TS Muxer

Because SRT uses MPEG-TS, you must explicitly specify the format using -f mpegts. You can also configure specific MPEG-TS parameters to optimize the stream:

3. Configure SRT Destination Parameters

The output URL must use the srt:// schema. You can append configuration parameters to the URL query string, such as:


Practical Command Examples

Example 1: Multiplexing One Video and Two Audio Tracks

This command takes a video file and two separate audio files, multiplexes them into a single MPEG-TS stream, and pushes it to an SRT receiver.

ffmpeg -re -i video.mp4 -i audio_en.wav -i audio_es.wav \
-map 0:v -map 1:a -map 2:a \
-c:v libx264 -preset veryfast -b:v 3000k \
-c:a aac -b:a 128k \
-f mpegts "srt://192.168.1.50:9000?mode=caller&latency=250000&pkt_size=1316"

Example 2: Multiplexing Video, Audio, and Telemetry Data

If you need to stream video, audio, and synchronous data (like GPS or sensor telemetry via timed metadata), you can multiplex them like this:

ffmpeg -re -i camera_feed.mp4 -i telemetry_data.srt \
-map 0:v -map 0:a -map 1:s \
-c:v copy -c:a copy -c:s text \
-f mpegts "srt://192.168.1.50:9000?mode=caller&latency=200000"

Troubleshooting and Key Considerations