Record SRT Live Streams to MPEG-TS Using FFmpeg
Capturing a live Secure Reliable Transport (SRT) feed and saving it
directly to an MPEG-TS container is a standard workflow for reliable
video archival and contribution feeds. FFmpeg allows you to listen for
or connect to an SRT stream and write the payload directly into a
.ts file without re-encoding, preserving 100% of the
original stream quality while using minimal CPU resources. This guide
covers the essential commands, connection modes, and key parameters
required to capture your SRT stream reliably.
Basic Capture Command
To capture an SRT stream and save it directly to an MPEG-TS file, use
stream copying (-c copy).
ffmpeg -i "srt://127.0.0.1:9000?mode=listener" -c copy -f mpegts output.tsChoosing the Correct SRT Mode
The configuration of your input URL depends on whether FFmpeg is receiving an incoming stream or actively fetching a stream from a server.
1. Listener Mode (Receiving a Push)
Use mode=listener if your source (such as OBS, vMix, or
a hardware encoder) is configured to push the stream to your FFmpeg
machine.
ffmpeg -i "srt://0.0.0.0:9000?mode=listener" -c copy output.ts0.0.0.0: Binds FFmpeg to all local network interfaces on port 9000.- Ensure your firewall allows incoming UDP traffic on the specified port.
2. Caller Mode (Pulling a Stream)
Use mode=caller if you are connecting to a remote SRT
server or streaming device that is already waiting for connections.
ffmpeg -i "srt://192.168.1.50:9000?mode=caller" -c copy output.tsKey Parameters Explained
-i "srt://...": Defines the SRT source URL and connection query parameters.-c copy: Bypasses decoding and re-encoding. Video and audio packets are muxed directly into the destination container as-is, saving CPU usage and avoiding generation loss.-f mpegts: Forces the output format to MPEG-TS (though FFmpeg will automatically infer this from the.tsextension).output.ts: The destination file where the recorded stream will be stored.
Recommended Production Settings
In production environments with variable network conditions, you can add query parameters to the SRT URL to handle packet loss and latency buffers:
ffmpeg -i "srt://0.0.0.0:9000?mode=listener&latency=2000000&timeout=5000000" -c copy -copyts output.tslatency=2000000: Sets the SRT receive buffer latency to 2,000,000 microseconds (2 seconds) to compensate for jitter and packet loss.timeout=5000000: Sets the connection timeout to 5 seconds.-copyts: Preserves the original input timestamps, which is critical for broadcast streams to avoid timing drift or audio/video sync issues.