Measure Frame Complexity with FFmpeg Entropy
This article explains how to use the FFmpeg entropy
video filter to calculate and export the visual complexity of individual
video frames. By measuring Shannon entropy across luminance and
chrominance planes, you can programmatically detect flat scenes,
identify high-detail frames, and analyze information density across your
media files.
Understanding the Entropy Filter
The entropy filter measures the randomness or
information density of pixel values in each frame. A lower entropy value
indicates low visual complexity (such as a solid black screen, a flat
sky, or a static graphic), while a higher entropy value indicates high
visual complexity (such as detailed textures, foliage, or noise).
By default, the filter evaluates the normal entropy of each color plane:
lavfi.entropy.entropy.normal.Y: Luminance (brightness) complexitylavfi.entropy.entropy.normal.U: Chrominance (blue projection) complexitylavfi.entropy.entropy.normal.V: Chrominance (red projection) complexity
Measuring and Logging Frame Entropy
To compute entropy values and output them to a text file for
analysis, combine the entropy filter with the
metadata filter.
Run the following command:
ffmpeg -i input.mp4 -vf "entropy=mode=normal,metadata=mode=print:file=entropy_log.txt" -f null -Command Breakdown:
-i input.mp4: Specifies the input video file.-vf "...": Creates the video filtergraph.entropy=mode=normal: Calculates standard Shannon entropy per frame.metadata=mode=print:file=entropy_log.txt: Intercepts the generated frame metadata and writes the key-value pairs directly toentropy_log.txt.
-f null -: Discards the processed video output to maximize processing speed without generating a heavy output video file.
Extracting Clean Values Using FFprobe
If you prefer structured output (such as CSV or JSON) for data
analysis or automated scripting, use ffprobe with the
lavfi virtual device:
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 > luminance_entropy.csvThis outputs lines containing only the timestamp and the luminance entropy value:
0.000000,4.218532
0.040000,4.225109
0.080000,4.319084
Measuring Temporal Differences
The entropy filter also supports measuring the
complexity of changes between consecutive frames using the
diff mode:
ffmpeg -i input.mp4 -vf "entropy=mode=diff,metadata=mode=print:key=lavfi.entropy.entropy.diff.Y:file=diff_entropy.txt" -f null -In diff mode, the filter measures the entropy of the
difference between the current frame and the previous frame. This
provides a quantitative metric for motion intensity or scene
transitions, where low values represent static camera shots and high
values represent fast motion or scene cuts.