Adjust Video Black and White Points with FFmpeg colorlevels

This article explains how to use the FFmpeg colorlevels filter to adjust the black and white points of a video. You will learn the basic syntax of the filter, how to target specific color channels, and see practical command-line examples to improve video contrast, brightness, and color balance.

Understanding the colorlevels Filter

The colorlevels filter in FFmpeg adjusts video levels by modifying the input and output ranges of individual color channels (Red, Green, Blue, and Alpha). By changing these ranges, you can crush shadows (adjust black points) or boost highlights (adjust white points).

The filter uses the following parameters for each color channel (using Red as the example):

The same naming convention applies to Green (gimin, gimax, gomin, gomax), Blue (bimin, bimax, bomin, bomax), and Alpha (aimin, aimax, aomin, aomax). All values range from -1.0 to 1.0, though standard adjustments typically fall between 0.0 and 1.0.

How to Adjust Black and White Points

To increase the contrast of a washed-out video, you need to bring the input minimum (black point) up and the input maximum (white point) down.

1. Simple Contrast Adjustment (All Channels)

To apply a uniform adjustment to the Red, Green, and Blue channels, you must specify the parameters for each channel individually in the filter chain:

ffmpeg -i input.mp4 -vf "colorlevels=rimin=0.05:gimin=0.05:bimin=0.05:rimax=0.95:gimax=0.95:bimax=0.95" -c:a copy output.mp4

What this does: * rimin/gimin/bimin=0.05: Raises the black point. Any pixel value below 5% brightness is forced to pure black, darkening the shadows. * rimax/gimax/bimax=0.95: Lowers the white point. Any pixel value above 95% brightness is forced to pure white, brightening the highlights.

2. Crushing Shadows (Deepening Blacks)

If your video looks hazy and you only want to darken the shadows without affecting the highlights, increase only the input minimum parameters:

ffmpeg -i input.mp4 -vf "colorlevels=rimin=0.08:gimin=0.08:bimin=0.08" -c:a copy output.mp4

3. Boosting Highlights (Brightening Whites)

To make a dim video brighter by expanding the white range without changing the dark areas, decrease only the input maximum parameters:

ffmpeg -i input.mp4 -vf "colorlevels=rimax=0.90:gimax=0.90:bimax=0.90" -c:a copy output.mp4

4. Color Tint Correction

You can also use the colorlevels filter to correct color casts. For example, if your video has an unwanted yellow tint, you can boost the blue channel’s white point to neutralize the warmth:

ffmpeg -i input.mp4 -vf "colorlevels=bimax=0.85" -c:a copy output.mp4