How to Stream SRT Live Video using FFmpeg Listener
This article provides a quick guide on how to configure and run an FFmpeg command to stream live video over the Secure Reliable Transport (SRT) protocol using listener mode. You will learn the exact command-line syntax, understand the key parameters required for listener mode, and see how a remote client can connect to ingest your stream.
Understanding SRT Listener Mode
In an SRT connection, one side must act as the listener (waiting for a connection) and the other as the caller (initiating the connection). When you configure FFmpeg as an SRT listener, it opens a local port and waits for a playback device, CDN, or receiver to connect and pull the live stream.
The FFmpeg Command
To stream a video file or live input as an SRT listener, use the following command structure:
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -b:v 3000k -c:a aac -f mpegts "srt://0.0.0.0:9000?mode=listener"Parameter Breakdown
-re: Read input at the native frame rate. This is required when streaming a static file to simulate a live feed. Skip this if your input is a real-time capture device.-i input.mp4: Your input source (can be a local video file, a webcam, or a capture card).-c:v libx264 -preset veryfast -b:v 3000k: Encodes the video to H.264 format with a target bitrate of 3000 kbps, optimized for low-latency live streaming.-c:a aac: Encodes the audio using the AAC codec.-f mpegts: Forces the container format to MPEG-TS, which is the standard transport container for SRT."srt://0.0.0.0:9000?mode=listener": The output URL.0.0.0.0tells FFmpeg to listen on all network interfaces of the host machine.9000is the UDP port being opened for the stream.?mode=listenerexplicitly configures FFmpeg to wait for incoming connections rather than trying to connect to a remote server.
How to Connect and Receive the Stream
Because FFmpeg is running as the listener, the receiver must connect as a caller.
To play the stream using another instance of FFmpeg (or a compatible player like VLC), point the receiving application to the IP address of the streaming machine using the caller mode:
ffplay "srt://<STREAMER_IP_ADDRESS>:9000?mode=caller"Replace <STREAMER_IP_ADDRESS> with the actual IP
address of the machine running the FFmpeg listener command. Make sure
that your system’s firewall allows incoming UDP traffic on your chosen
port (port 9000 in this example).