Stream SRT to Multiple Destinations Using FFmpeg

This article explains how to use FFmpeg to split and push a single live stream to multiple SRT (Secure Reliable Transport) destinations simultaneously. You will learn the core FFmpeg commands, specifically utilizing the tee muxer, to achieve efficient, low-latency multi-streaming without overloading your CPU.

To push a live stream to multiple SRT servers, you should avoid encoding the stream multiple times. Instead, encode the stream once and use FFmpeg’s tee muxer to duplicate the output and send it to your target SRT destinations.

The FFmpeg Command

Below is the standard command template for capturing an input stream, encoding it, and distributing it to two different SRT servers using the tee muxer:

ffmpeg -re -i input_source -c:v libx264 -preset veryfast -g 60 -b:v 4000k \
-c:a aac -b:a 128k -f tee -map 0:v -map 0:a \
"[f=mpegts]srt://server1.example.com:9000?mode=caller|[f=mpegts]srt://server2.example.com:9000?mode=caller"

Command Breakdown

Handling Connection Failures

By default, if one of the SRT destinations fails or disconnects, the entire FFmpeg process may stop. To prevent a single server failure from interrupting the other stream, add the onfail=ignore option to the tee muxer configuration:

"[f=mpegts:onfail=ignore]srt://server1.example.com:9000|[f=mpegts:onfail=ignore]srt://server2.example.com:9000"

Using this syntax, FFmpeg will continue pushing the live stream to the active server even if the other connection drops.