Measure CPU Times with FFmpeg Benchmark Mode

This article explains how to use FFmpeg’s built-in benchmarking features to measure CPU performance during media processing. You will learn the specific command-line flags required to trigger benchmark mode, how to read the resulting console output, and what the user and system CPU times mean for your system’s performance.

To run an FFmpeg command in benchmark mode, you need to add the -benchmark option to your command. This flag instructs FFmpeg to measure and display CPU usage and execution time once the processing is complete.

The Benchmark Command

To measure CPU times, place the -benchmark flag before or after your input, but before the output file. Here is a standard template:

ffmpeg -benchmark -i input.mp4 -c:v libx264 -preset fast output.mp4

For more detailed performance tracking across individual steps of the pipeline (like decoding, filtering, and encoding), you can use the -benchmark_all flag instead:

ffmpeg -benchmark_all -i input.mp4 -c:v libx264 -preset fast output.mp4

Understanding the Benchmark Output

Once the FFmpeg process finishes, the terminal will display a summary block containing the benchmark results. The output looks similar to this:

bench: utime=12.450s stime=1.120s rtime=4.850s maxrss=148532KiB

These values represent the following metrics:

Analyzing the Results

To determine how efficiently FFmpeg is utilizing your CPU, compare the sum of the CPU times (utime + stime) against the real elapsed time (rtime).

If your system has a multi-core processor and FFmpeg is utilizing multiple threads, the combined CPU time (utime + stime) can be significantly higher than the real time (rtime). For example, if utime is 20 seconds and rtime is 5 seconds, FFmpeg successfully parallelized the workload across an average of 4 CPU cores.