FFmpeg Colorbalance: Adjust Shadows Midtones Highlights

This article provides a practical guide on how to use the FFmpeg colorbalance filter to adjust the color levels of a video’s shadows, midtones, and highlights independently. You will learn the exact syntax of the filter, understand how the parameters map to different tonal ranges, and see real-world command-line examples for color grading and correction.

The colorbalance filter in FFmpeg allows you to adjust the balance of primary colors (Red, Green, and Blue) in three specific tone regions of an image or video: shadows, midtones, and highlights. This is highly useful for correcting color casts, warming up or cooling down specific areas of a video, or achieving creative color-grading styles.

The Colorbalance Parameters

The filter uses nine main parameters, divided into three categories based on the tonal range. Each parameter accepts a value from -1.0 (to decrease the color) to 1.0 (to increase the color), with 0.0 being the default (no change).

Basic Syntax

To use the filter, apply the -vf (video filter) flag followed by colorbalance and your desired parameters:

ffmpeg -i input.mp4 -vf "colorbalance=rs=0.1:gs=0.0:bs=-0.1:rm=0.0:gm=0.1:bm=0.0:rh=-0.1:gh=0.0:bh=0.2" -c:a copy output.mp4

Practical Examples

1. Warming Up the Midtones and Highlights

To give your video a warmer, more golden-hour look, you can increase the red and decrease the blue in the midtones and highlights:

ffmpeg -i input.mp4 -vf "colorbalance=rm=0.15:bm=-0.1:rh=0.1:bh=-0.1" -c:a copy output.mp4

2. Cooling Down the Shadows

If you want a cinematic “teal and orange” look, you can cool down the shadows by adding blue and cyan (by reducing red), while keeping the midtones warm:

ffmpeg -i input.mp4 -vf "colorbalance=rs=-0.1:bs=0.15:rm=0.1:bm=-0.05" -c:a copy output.mp4

3. Correcting a Green Color Cast

If your video was shot under fluorescent lighting and has an unwanted green tint, you can reduce green in the midtones and highlights, or slightly increase red and blue to neutralize it:

ffmpeg -i input.mp4 -vf "colorbalance=gm=-0.1:gh=-0.1" -c:a copy output.mp4

Tips for Fine-Tuning