Configure FFmpeg Colorlevels Filter RGB Levels

This article explains how to use the FFmpeg colorlevels video filter to adjust the input and output minimum and maximum levels for the red, green, and blue channels. By manipulating these parameters, you can perform precise color correction, contrast adjustment, and black/white point mapping directly from the command line.

Understanding the Colorlevels Parameters

The colorlevels filter allows you to adjust the black point, white point, and output brightness range for each individual color channel: Red (r), Green (g), Blue (b), and Alpha (a).

Each channel has four configurable parameters: * Input Minimum (imin): Specifies the input level that will be mapped to the output minimum. Any input value below this will be clipped to the output minimum. * Input Maximum (imax): Specifies the input level that will be mapped to the output maximum. Any input value above this will be clipped to the output maximum. * Output Minimum (omin): Specifies the target minimum level for the output. * Output Maximum (omax): Specifies the target maximum level for the output.

The parameters are prefixed with the channel letter (r, g, b, or a). All values are represented as floating-point numbers between 0.0 and 1.0.

Channel Input Min Input Max Output Min Output Max
Red rimin rimax romin romax
Green gimin gimax gomin gomax
Blue bimin bimax bomin bomax
Alpha aimin aimax aomin aomax

Practical Examples

1. Increasing Video Contrast

To increase the contrast of your video, you can crush the blacks (raise the input minimums) and boost the whites (lower the input maximums).

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

In this command, any input values below 0.05 become pure black (0.0), and any input values above 0.95 become pure white (1.0) for all RGB channels.

2. Reducing Contrast (Fading the Video)

To compress the dynamic range of your video, keep the input range at default (0.0 to 1.0) but narrow the output range. This will make your blacks lighter and your whites darker.

ffmpeg -i input.mp4 -vf "colorlevels=romin=0.1:gomin=0.1:bomin=0.1:romax=0.9:gomax=0.9:bomax=0.9" -c:a copy output.mp4

Here, the darkest possible output color is limited to 0.1, and the brightest possible output color is capped at 0.9.

3. Fixing Color Casts (Color Correction)

If your video has an unwanted color cast—such as a strong green tint—you can lower the maximum intensity of the green channel to bring the colors back into balance.

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

This command scales down the highlight threshold of the green channel, reducing its overall presence in the brighter areas of the video.

4. Warm Photographic Filter (Tinting)

To apply a warm, stylized tint to your video, you can raise the output minimum of the red channel and slightly decrease the output maximum of the blue channel.

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

This pushes warmer tones into the shadows while pulling cool tones out of the highlights.