Measure Frame Complexity with FFmpeg Entropy Filter

This article explains how to use the FFmpeg entropy filter to measure the visual complexity of individual video frames. You will learn how the filter works, how to run the command to extract entropy values, and how to export this metadata for analysis.

What is Video Frame Entropy?

In information theory, entropy is a measure of randomness or information density. When applied to video frames, the entropy filter calculates the Shannon entropy of the color channels (such as YUV or RGB).

Measuring this complexity is highly useful for optimizing compression settings, detecting scene cuts, or analyzing video quality.


Step 1: Analyze Frames with FFmpeg and Showinfo

To quickly view the entropy values of each frame in your terminal, combine the entropy filter with the showinfo filter.

Run the following command:

ffmpeg -i input.mp4 -vf entropy,showinfo -f null -

Understanding the Output

In the terminal output, look for the lines generated by showinfo. You will see metadata keys assigned to each frame:

[Parsed_showinfo_1 @ 0x...]   metadatapool:
[Parsed_showinfo_1 @ 0x...]     lavfi.entropy.entropy.normal.Y=7.12
[Parsed_showinfo_1 @ 0x...]     lavfi.entropy.entropy.normal.U=4.34
[Parsed_showinfo_1 @ 0x...]     lavfi.entropy.entropy.normal.V=4.12

Step 2: Export Frame Complexity Data Using FFprobe

If you want to save this data to a CSV or text file for analysis (such as graphing the complexity over time), use ffprobe. It allows you to parse the filter metadata and output it in a structured format.

Run this command to output the timestamp and the luminance (Y) entropy of each frame into a CSV format:

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

Resulting CSV Format:

The output file complexity_data.csv will contain data structured like this:

0.000000,5.124512
0.040000,5.131092
0.080000,6.452109
0.120000,6.891230

Step 3: Target Specific Color Channels (Optional)

By default, the entropy filter measures normal entropy. You can customize the filter behavior by specifying options.

For example, to measure only the luminance channel to save processing power:

ffmpeg -i input.mp4 -vf entropy=mode=normal -f null -

The available modes are: * normal: Standard Shannon entropy (default). * diff: Measures the entropy of the difference between consecutive pixels, which is highly sensitive to edges and fine details.