Monitor SRT Packet Loss and Latency with FFmpeg
Monitoring the packet loss and latency of an active Secure Reliable Transport (SRT) connection in FFmpeg allows broadcasters to diagnose network instability and prevent stream degradation before it impacts viewers. While FFmpeg does not have a dedicated graphical interface for network diagnostics, it exposes libsrt's internal statistics through its debug logging pipeline. By running FFmpeg with elevated log levels and parsing standard error output, you can monitor Round-Trip Time (RTT), lost packets, and dropped frames in real time.
Enable SRT Debug Logging
By default, FFmpeg suppresses low-level protocol statistics. To
capture SRT metrics such as latency and packet loss, set the logging
level to debug using the -loglevel debug
flag.
Run your stream command with debug logging enabled:
ffmpeg -loglevel debug -re -i input.mp4 -c copy -f mpegts "srt://192.168.1.100:9000?mode=caller"Because FFmpeg outputs all logs and connection statistics to
stderr, libsrt will print periodic connection reports
containing real-time transmission metrics directly to your terminal.
Key Metrics to Monitor
When debug logging is active, libsrt outputs statistical lines throughout the streaming session. Focus on the following key parameters:
- rttMS / rtt: The Round-Trip Time in milliseconds. This represents the real-time network latency between the sender and receiver.
- pktSndLoss / pktRcvLoss: The total count of transmitted or received packets reported lost by the transport layer.
- pktRcvRetrans / pktSndRetrans: The number of retransmitted packets requested to recover from loss.
- pktRcvDrop / pktSndDrop: Packets dropped because they did not arrive within the configured SRT latency buffer window. If this number increases, your configured latency is too low for the current network conditions, leading to visible artifacts or frame drops.
- byteFlightSize: The amount of data currently in transit and unacknowledged.
Filtering Metrics in Real Time
Because -loglevel debug produces high-volume output that
can obscure performance metrics, redirect stderr to
stdout and filter for SRT statistics using command-line
utilities.
On Linux and macOS (Bash):
ffmpeg -loglevel debug -re -i input.mp4 -c copy -f mpegts "srt://192.168.1.100:9000?mode=caller" 2>&1 | grep -i --line-buffered -E "rtt|loss|drop"On Windows (PowerShell):
ffmpeg -loglevel debug -re -i input.mp4 -c copy -f mpegts "srt://192.168.1.100:9000?mode=caller" 2>&1 | Select-String "rtt", "loss", "drop"This filters the terminal stream to display only updates concerning RTT, packet loss, and dropped frames.
Log to a File for Post-Stream Analysis
To analyze network performance without impacting live terminal
performance, use FFmpeg's -report flag. This dumps the
complete debug output, including timestamped SRT statistics, into a log
file in the working directory:
FFREPORT=file=srt_debug.log:level=48 ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://192.168.1.100:9000?mode=caller"After the transmission completes, search srt_debug.log
for peak RTT values and cumulative loss figures to determine if the SRT
latency buffer (?latency=<microseconds>) requires
adjustment for future broadcasts.