How to Stream SRT in Listener Mode Using FFmpeg
Streaming video over Secure Reliable Transport (SRT) provides low-latency, packet-loss-resilient video transmission across unpredictable public networks. While most streaming setups use SRT in caller mode to push data to an external server, FFmpeg also supports listener mode, allowing your FFmpeg instance to act as a server that waits for incoming connections. This guide covers how to configure FFmpeg to stream or receive video over SRT in listener mode, along with the essential flags and testing procedures.
Prerequisites
Your FFmpeg installation must be compiled with the
libsrt library. You can verify this by running:
ffmpeg -protocols | grep srtIf srt appears in the list under both Input and Output,
your build is ready.
Streaming as a Server (Sending Video to a Caller)
In this scenario, FFmpeg encodes a video source (such as a local file, test pattern, or capture card) and waits on a specified port for a remote player or receiver to connect and pull the stream.
Run the following command:
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k -c:a aac -b:a 128k -f mpegts "srt://0.0.0.0:9000?mode=listener"Parameter Breakdown:
-re: Reads the input file at native frame rate (omit this if capturing live input).-c:v libx264&-c:a aac: Encodes the stream using H.264 video and AAC audio.-f mpegts: Packages the stream into the MPEG-TS container, which is standard for SRT.srt://0.0.0.0:9000: Binds the SRT server to port9000across all available network interfaces.?mode=listener: Instructs the SRT protocol handler to wait for an incoming connection instead of trying to initiate one.
Ingesting as a Server (Receiving Video from a Caller)
If an external encoder (such as OBS Studio or a hardware camera) is sending a stream to your machine, FFmpeg can listen for that incoming stream and record or process it.
Run the following command to record an incoming SRT caller stream:
ffmpeg -i "srt://0.0.0.0:9000?mode=listener" -c copy output.mp4FFmpeg will open port 9000, wait until the remote
encoder connects, and then mux the incoming packets directly to
output.mp4 without re-encoding.
Essential SRT Parameters
You can append additional query parameters to the SRT URL to fine-tune network performance:
latency: Sets the buffer latency in microseconds. For example,latency=200000sets the latency to 200 milliseconds to compensate for jitter and packet loss.pkt_size: Specifies the maximum payload size (typically1316for standard MPEG-TS packets over Ethernet).passphrase: Enables AES encryption. A client must supply the same passphrase to connect.pbkeylen: Sets the encryption key length (e.g.,16,24, or32bytes for AES-128, AES-192, or AES-256).
Example with tuning:
ffmpeg -re -i input.mp4 -c:v libx264 -f mpegts "srt://0.0.0.0:9000?mode=listener&latency=200000&pkt_size=1316"Connecting to the Listener Stream
Once FFmpeg is running in listener mode, any SRT client can connect in caller mode.
To play the stream on another machine using ffplay:
ffplay "srt://<LISTENER_IP>:9000?mode=caller"Replace <LISTENER_IP> with the local or public IP
address of the machine running the FFmpeg listener. Ensure that UDP port
9000 is open on your firewall and properly forwarded if
connecting across routers.