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

By 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 between 10 and 30 eliminates 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 from 0.0 (unaltered) to 1.0 (fully normalized). A value like 0.8 provides subtle dynamic range expansion.
  • blackpt and whitept: Sets the target color bounds for the lowest and highest values. The defaults are black and white.

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

In this command:

  • smoothing=25 averages the range over approximately one second of footage (at 24–30 fps) to keep transitions smooth.
  • independence=0 ensures color fidelity remains intact.
  • strength=0.9 prevents harsh clipping at the extreme ends of the spectrum.
  • -c:a copy preserves the original audio stream without re-encoding.