Capture SRT Live Stream to MPEG-TS with FFmpeg

This article provides a quick guide on how to capture a Secure Reliable Transport (SRT) live stream and save it directly to an MPEG-TS (.ts) file using FFmpeg. You will learn the exact command-line syntax for both Caller and Listener modes, how to configure crucial SRT latency parameters, and how to record the stream without re-encoding to save CPU resources.

The Basic FFmpeg Command

To capture an SRT stream and save it to an MPEG-TS container without re-encoding the video and audio, use the following basic command:

ffmpeg -i "srt://<IP_ADDRESS>:<PORT>?mode=caller" -c copy -f mpegts output.ts

Parameter Breakdown


Scenario 1: FFmpeg as a Caller (Pulling the Stream)

If you are pulling a stream from an external SRT source that is configured as a listener, run FFmpeg in caller mode. You must specify the remote server’s IP address and port.

ffmpeg -i "srt://192.168.1.50:9000?mode=caller&latency=200000" -c copy -f mpegts output.ts

Note: The latency parameter is defined in microseconds. 200000 equals 200 milliseconds of latency buffer, which helps prevent packet loss over unstable networks.


Scenario 2: FFmpeg as a Listener (Receiving a Pushed Stream)

If a camera, encoder, or external server is pushing (calling) the SRT stream to your machine, you must set FFmpeg to listener mode. Use 0.0.0.0 to bind to all network interfaces on your local machine.

ffmpeg -i "srt://0.0.0.0:9000?mode=listener" -c copy -f mpegts output.ts

Once you run this command, FFmpeg will pause and wait for the incoming SRT connection before it starts writing the output.ts file.


Important SRT Query Parameters

You can append several parameters to the SRT URL to optimize the connection: