Measure FFmpeg Encoding Speed and Frame Rate in Real-Time

Monitoring the performance of an FFmpeg process is crucial for optimizing video processing pipelines. This article explains how to measure FFmpeg encoding speed and frame rate in real-time using built-in command-line outputs, progress logging flags, and terminal-based parsing to capture live performance metrics.

Method 1: Reading the Interactive Console Output

By default, when you run an FFmpeg command in your terminal, it displays a live-updating status line at the bottom of the console. This is the simplest way to monitor performance manually.

During an active encode, look for the following key metrics in the console output:

Method 2: Using the -progress Flag for Programmatic Monitoring

If you need to parse performance data programmatically using Python, Node.js, or Bash, parsing the standard terminal output can be unreliable. FFmpeg provides a dedicated -progress option that outputs clean, machine-readable key-value pairs to a file, a pipe, or the standard output.

To pipe the real-time progress metrics directly to your terminal output, use the following syntax:

ffmpeg -i input.mp4 -progress - output.mp4

Using -progress - redirects the performance stream to stdout. Every second, FFmpeg will output a block of text containing specific metrics:

frame=1240
fps=59.8
stream_0_0_q=28.0
bitrate= 1850.4kbits/s
total_size=12582912
out_time_us=54000000
out_time_ms=54000000
out_time=00:00:54.000000
dup_frames=0
drop_frames=0
speed=2.15x
progress=continue

Method 3: Filtering Real-Time Metrics via Command Line

If you want to view only the speed and frame rate in your terminal without the rest of the verbose FFmpeg output, you can combine the -progress flag with command-line utilities like grep or awk to filter the stream in real-time.

Run the following command to filter and print only the fps and speed values as they update:

ffmpeg -i input.mp4 -progress - output.mp4 2>&1 | grep -E "^(fps|speed)="

Explanation of the command: