Detecting and Logging Dropped Video Frames in FFmpeg

This article provides a practical guide on how to identify and log dropped frames during video processing using FFmpeg on a Linux environment. You will learn the specific command-line flags required to surface drop statistics, how to interpret the console output, and how to redirect these metrics into a dedicated log file for automated analysis.

Understanding Dropped Frames in FFmpeg

When FFmpeg processes a video—whether it is decoding, encoding, or streaming—it expects a consistent flow of timestamps. If your system encounters hardware bottlenecks (like high CPU utilization or slow disk I/O) or if the input live stream suffers from network jitter, FFmpeg may be forced to drop frames to keep up.

By default, FFmpeg prints a summary of frame statistics to the standard error stream (stderr), but capturing the exact moment and frequency of dropped frames requires specific configuration.

The Standard FFmpeg Command for Monitoring Drops

To actively monitor frame drops during a conversion or streaming process, you can utilize the -loglevel and -stats flags. Here is a baseline command template:

ffmpeg -i input.mp4 -loglevel info -vsync cfr output.mp4

While the video processes, keep your eyes on the console status line. FFmpeg continuously updates a string that looks similar to this:

frame= 412 fps= 30 q=28.0 size= 4608kB time=00:00:13.73 bitrate=2748.1kbits/s speed=0.98x drop=12

The key metric here is drop=12. This explicitly tells you that 12 frames have been discarded since the processing started. If this number stays at 0, your system is processing the video smoothly without losing data.

Logging Dropped Frames to a File

If you are running automated scripts or need to analyze the logs after a long encode, viewing the live console isn’t enough. Because FFmpeg outputs its progress reports to stderr, you must redirect that stream to a text file.

You can capture the full operational log by appending redirection operators at the end of your Linux command:

ffmpeg -i input.mp4 output.mp4 > ffmpeg_output.log 2>&1

In this command:

Filtering the Log for Dropped Frames

Because the resulting log file can be incredibly dense, you can use standard Linux command-line utilities like grep to isolate the instances where frames were dropped.

If you want to scan an existing log file specifically for lines containing drop statistics, use the following command:

grep -E "drop=[1-9]" ffmpeg_output.log

This regular expression filters the log and displays only the lines where the drop= count is greater than zero, allowing you to pinpoint exactly when the performance degradation occurred during the video timeline.