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:

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.mp4

2. 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.mp4

3. 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.mp4

In 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.