Analyze Frame Complexity with FFmpeg Entropy Filter

The FFmpeg entropy filter is a powerful tool for measuring the information density and complexity of video frames. By analyzing the distribution of pixel values, this filter helps developers, video engineers, and researchers identify scene changes, detect encoding anomalies, and measure visual complexity. This guide provides a direct, step-by-step walkthrough on how to apply the entropy filter, interpret its metadata, and export the analysis for further processing.

Understanding the Entropy Filter

In video processing, “entropy” refers to the randomness or amount of information contained within a frame. * Low Entropy: Frames with flat colors, solid backgrounds, or very little detail (e.g., a black screen or simple vector graphics) have low entropy. * High Entropy: Frames with high detail, complex textures, motion blur, or noise (e.g., confetti, crowd scenes, or water ripples) have high entropy.

The entropy filter measures this value for each channel—typically Luma (Y) and Chroma (U and V)—and assigns metadata keys to each analyzed frame.

Basic Command to Run Entropy Analysis

Because the entropy filter outputs metadata rather than altering the visual appearance of the video, you must use it in combination with a tool that can read frame metadata, such as ffprobe.

To print the Luma (Y) entropy for every frame in a video to your terminal, use the following ffprobe command:

ffprobe -v error -f lavfi -i "movie=input.mp4,entropy" -show_entries frame=pkt_pts_time:frame_tags=lavfi.entropy.entropy.Y -of default=noprint_wrappers=1

Explaining the Metadata Keys

When you run the analysis, the filter generates several keys per frame. The most useful keys include:

Exporting Complexity Data to CSV

For deep analysis, graphing, or machine learning pipelines, you will likely want to save these complexity metrics to a CSV file. Run the following command to generate a clean, comma-separated list containing the timestamp and the corresponding Luma entropy value:

ffprobe -v error -f lavfi -i "movie=input.mp4,entropy" -show_entries frame=pkt_pts_time:frame_tags=lavfi.entropy.entropy.Y -of csv=p=0 > entropy_report.csv

The resulting entropy_report.csv will look like this:

0.000000,5.124502
0.040000,5.132114
0.080000,5.150873
0.120000,6.891240

Drawing Entropy Values on the Video

If you want to visually inspect how complexity correlates with your video content, you can burn the real-time entropy values directly onto the video using the drawtext filter.

ffmpeg -i input.mp4 -vf "entropy,drawtext=text='Luma Entropy\: %{metadata\:lavfi.entropy.entropy.Y}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4

This creates a new video file (output.mp4) with a black-and-white text overlay in the top-left corner displaying the exact visual complexity of the current frame in real-time.