FFmpeg Normalize Filter Temporal Smoothing and Targets

This article provides a quick guide on how to configure the normalize video filter in FFmpeg to enhance video contrast. You will learn how to use the temporal smoothing parameter to prevent video flickering and how to define custom black and white color targets to control the intensity of the normalization process.

Understanding the FFmpeg Normalize Filter

The normalize filter in FFmpeg scales the blue, green, and red channels of a video so that the darkest pixels become black (or a specified target color) and the brightest pixels become white (or another specified target color).

By default, the filter assesses and processes each frame individually. While this maximizes contrast, it can lead to aggressive brightness shifts—known as flickering—when the content of the video changes rapidly. To resolve this, you can configure temporal smoothing alongside custom black and white points.

Configuring Temporal Smoothing

Temporal smoothing averages the normalization bounds over a specified number of consecutive frames. This prevents sudden jumps in contrast and ensures smooth transitions.

You can configure this using the smoothing (or s) option. It accepts an integer representing the number of frames to look ahead and behind for calculating the average.

Example syntax:

normalize=smoothing=15

Configuring Black and White Targets

By default, the filter stretches the input range to absolute black (0x000000) and absolute white (0xFFFFFF). However, you can map the minimum and maximum levels to custom colors using the blackpt (or b) and whitept (or w) options.

These parameters accept color names (such as black, white, gray) or hexadecimal values (such as 0x101010).

For example, to prevent the filter from crushing the shadows or blowing out the highlights, you can set the targets to slightly softer gray tones instead of absolute black and white:

normalize=blackpt=0x080808:whitept=0xf0f0f0

Putting It Together: Practical Command Examples

To apply both temporal smoothing and custom target colors, separate the arguments with colons within the filter string.

Example 1: Standard Smoothing with Softer Contrast

This command uses a 15-frame smoothing window and restricts the output range slightly to avoid harsh contrast:

ffmpeg -i input.mp4 -vf "normalize=smoothing=15:blackpt=0x050505:whitept=0xfafafa" -c:a copy output.mp4

Example 2: High Smoothing with Named Colors

This command applies a longer 30-frame smoothing window (ideal for slow-moving scenes) and maps the black point to a dark gray:

ffmpeg -i input.mp4 -vf "normalize=smoothing=30:blackpt=darkgray:whitept=white" -c:a copy output.mp4