FFmpeg Normalize Filter: Auto Contrast and Brightness
The normalize filter in FFmpeg provides an automated way
to optimize the dynamic range of video content by stretching brightness
and contrast values on a frame-by-frame basis. This guide covers how to
implement the normalize filter, configure essential
settings like temporal smoothing to prevent flickering, maintain color
accuracy by locking RGB channels, and fine-tune processing strength for
professional results.
Basic Syntax
To apply automatic normalization using default settings, pass the
normalize filter to the -vf (video filter)
flag:
ffmpeg -i input.mp4 -vf "normalize" -c:a copy output.mp4By default, this command analyzes each frame, finds the darkest pixel to map to black, and finds the brightest pixel to map to white.
Key Parameters
Using the default configuration on continuous video often causes unwanted artifacts such as sudden exposure flickering or shifting color tints. Adjusting the following parameters resolves these issues:
smoothing: Sets the number of frames over which the adjustment range is temporally averaged. A value between10and30eliminates abrupt brightness jumps between consecutive frames.independence: Determines whether color channels are processed independently.independence=1(default): Normalizes Red, Green, and Blue channels separately. This maximizes contrast but can cause severe color distortion.independence=0: Normalizes all channels together based on luminance, preserving the original color balance and hue.
strength: Adjusts the mix between the original frame and the normalized output, ranging from0.0(unaltered) to1.0(fully normalized). A value like0.8provides subtle dynamic range expansion.blackptandwhitept: Sets the target color bounds for the lowest and highest values. The defaults areblackandwhite.
Recommended Production Command
To achieve natural contrast and brightness correction without color shifts or exposure strobing, use the following command:
ffmpeg -i input.mp4 -vf "normalize=smoothing=25:independence=0:strength=0.9" -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4In this command:
smoothing=25averages the range over approximately one second of footage (at 24–30 fps) to keep transitions smooth.independence=0ensures color fidelity remains intact.strength=0.9prevents harsh clipping at the extreme ends of the spectrum.-c:a copypreserves the original audio stream without re-encoding.