Monitor SRT Stream Latency in Real-Time with FFmpeg

Secure Reliable Transport (SRT) is widely used for low-latency video streaming, but maintaining optimal performance requires active, real-time monitoring. This article explains how to analyze and monitor active SRT stream latency and network performance in real-time using FFmpeg’s built-in logging and statistics capabilities, helping you troubleshoot network jitter and delay issues instantly.

Enabling SRT Statistics in FFmpeg

FFmpeg allows you to enable real-time SRT statistics directly through the connection URI. By appending the stats=1 parameter to your SRT source or destination URL, FFmpeg will print detailed transport statistics to the console stderr stream.

To monitor an incoming SRT stream without decoding the video (saving CPU resources), use the following command:

ffmpeg -i "srt://YOUR_IP:PORT?mode=listener&stats=1" -f null -

If you are pushing an SRT stream and want to monitor the output latency, append the parameter to your output URI:

ffmpeg -i input.mp4 -f mpegts "srt://YOUR_IP:PORT?mode=caller&stats=1"

Adjusting the Monitoring Interval

By default, FFmpeg outputs the statistics block once every second (1000 milliseconds). If you need higher resolution tracking for micro-stuttering or rapid latency spikes, you can adjust the interval using the stats_interval parameter (defined in milliseconds).

For example, to receive updates every 500 milliseconds:

ffmpeg -i "srt://YOUR_IP:PORT?mode=listener&stats=1&stats_interval=500" -f null -

Understanding the Real-Time Latency Metrics

Once the stream is active, FFmpeg will output a continuous stream of metrics. To monitor latency and connection health, focus on the following key-value pairs in the log output:

Filtering the Output for Clean Monitoring

FFmpeg outputs a large amount of general log information, which can obscure the real-time SRT metrics. You can isolate the SRT statistics by redirection and filtering via grep:

ffmpeg -i "srt://YOUR_IP:PORT?mode=listener&stats=1" -f null - 2>&1 | grep --line-buffered "srt"

This command routes the standard error output to grep, displaying only the lines containing SRT statistics for a clean, real-time dashboard inside your terminal.