Use FFmpeg thistogram for Temporal Color Histograms
This article explains how to use the FFmpeg thistogram
filter to generate and display a temporal color histogram of a video.
You will learn the basic syntax of the filter, its key parameters for
customization, and practical command-line examples to view the histogram
on its own or side-by-side with your original video.
Understanding the thistogram Filter
Unlike a standard histogram that displays the color distribution of a
single frame, the thistogram (temporal histogram) filter
displays the color distribution of a video across successive frames over
time. It creates a scrolling visualization where each vertical column of
pixels represents the color histogram of a specific frame in the video
timeline.
This tool is highly useful for video analysis, color grading, and monitoring exposure transitions across a scene.
Key Parameters of the thistogram Filter
You can customize the output of the temporal histogram using several parameters:
width(orw): Sets the width of the output video. The default is 512.height(orh): Sets the height of the output video. The default is 512.display_mode(ord): Specifies how the histogram values are scaled.linear(default): Linear scaling.logarithmicorlog: Logarithmic scaling, which is useful for seeing details in darker or lower-density areas.
components(orc): A bitmask specifying which color components to display. The default is 7 (all components/planes).slide(ors): Sets the sliding mode of the histogram.frame: Shows the histogram moving frame by frame.scroll: Scrolls the histogram horizontally.
Practical Command Examples
1. Basic Temporal Histogram
To generate a standalone video consisting only of the temporal color histogram from an input video, use the following command:
ffmpeg -i input.mp4 -vf "thistogram" output.mp42. Custom Dimensions and Logarithmic Scaling
To make the histogram wider and use logarithmic scaling to better
analyze low-light details, configure the width,
height, and display_mode parameters:
ffmpeg -i input.mp4 -vf "thistogram=w=800:h=400:d=log" output.mp43. Displaying the Video and Histogram Side-by-Side
To view the original video and its temporal histogram simultaneously,
you can split the video stream, apply the thistogram filter
to one path, and combine them horizontally using the hstack
filter:
ffmpeg -i input.mp4 -filter_complex "[0:v]split[original][for_hist];[for_hist]thistogram=width=300[hist];[original][hist]hstack" output.mp4In this command: * split duplicates the input video into
two streams: original and for_hist. *
thistogram processes the duplicate stream and outputs it as
hist. * hstack stacks the
original video and the hist visualizer
side-by-side.