Configure FFmpeg SRT Caller or Listener Mode
This article provides a practical guide on how to configure Secure Reliable Transport (SRT) streaming in FFmpeg using either caller or listener mode. You will learn the difference between these two connection modes, the correct URL syntax for FFmpeg, and see clear command-line examples for setting up both sender and receiver configurations.
Understanding SRT Connection Modes
SRT requires one peer to act as a listener (waiting for an incoming connection) and the other to act as a caller (initiating the connection). Once the handshake is completed, data can flow in either direction. By default, FFmpeg operates in caller mode if no mode is explicitly defined.
Configuring Caller Mode
In caller mode, FFmpeg initiates the connection to a remote SRT listener. This is the most common setup when streaming from a local encoder to a remote ingestion server or CDN.
To configure caller mode, append ?mode=caller to your
SRT destination URL (or omit it, as it is the default).
Example: Sending a stream in caller mode
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -c:a aac -f mpegts "srt://192.168.1.100:9000?mode=caller"Example: Receiving a stream in caller mode
ffmpeg -i "srt://192.168.1.100:9000?mode=caller" -c copy output.mp4Configuring Listener Mode
In listener mode, FFmpeg binds to a local port and waits for a remote caller to initiate the connection. This is useful when you want to ingest a stream directly from a remote camera or encoder without using an intermediary server.
To configure listener mode, append ?mode=listener to the
SRT URL. You should typically bind to 0.0.0.0 to accept
connections on any network interface.
Example: Receiving a stream as a listener
ffmpeg -i "srt://0.0.0.0:9000?mode=listener" -c copy output.mp4Example: Sending a stream as a listener
ffmpeg -re -i input.mp4 -c:v libx264 -c:a aac -f mpegts "srt://0.0.0.0:9000?mode=listener"Key SRT Parameters to Include
When configuring either mode, you can append additional parameters to
the SRT query string using an ampersand (&).
- latency: Sets the latency in microseconds (e.g.,
2000000for 2 seconds). Both sides should ideally match this value. - passphrase: Enables AES encryption by specifying a password (must be between 10 to 79 characters).
- pbkeylen: Specifies the encryption key length in
bytes (
16for AES-128,24for AES-192,32for AES-256). Must be used withpassphrase. - streamid: A unique string used for multiplexing or identifying the stream, often required by cloud ingest portals.
Example with advanced parameters:
ffmpeg -re -i input.mp4 -f mpegts "srt://192.168.1.100:9000?mode=caller&latency=2000000&passphrase=MySecurePassword123&pbkeylen=32"