How to Use FFmpeg Colorbalance to Correct Color Cast

This article provides a practical guide on how to use the FFmpeg colorbalance filter to remove unwanted color casts from your videos. You will learn the basic syntax of the filter, understand how to target specific tonal ranges—shadows, midtones, and highlights—and see real-world command examples to restore natural colors to your footage.

The colorbalance filter in FFmpeg allows you to adjust the balance of primary colors (Red, Green, and Blue) in three distinct spectral bands: shadows, midtones, and highlights. This is highly effective for correcting white balance issues, such as a video looking too yellow, blue, or green.

Understanding the Parameter Syntax

The filter uses specific prefixes for each tonal range and color: * Shadows (s): rs (red), gs (green), bs (blue) * Midtones (m): rm (red), gm (green), bm (blue) * Highlights (h): rh (red), gh (green), bh (blue)

Each parameter accepts a value from -1.0 (to decrease the color) to 1.0 (to increase the color). The default value for all parameters is 0.0.

Practical Examples

1. Correcting a Warm (Yellow/Orange) Color Cast

If your video looks too warm or yellow, you need to reduce red and green, or increase blue. To fix this, you can slightly lower the red and green midtones and highlights while boosting the blue midtones and highlights.

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

2. Correcting a Cool (Blue) Color Cast

If your video has a cold, blue tint—often caused by incorrect outdoor white balance—you can counter this by reducing blue and slightly increasing red and green in the midtones and highlights.

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

3. Fixing a Green Cast (Fluorescent Lighting)

Fluorescent lights often introduce an unpleasant green tint to footage. To correct a green cast, reduce the green values across the midtones and highlights:

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

By adjusting these parameters incrementally, you can achieve precise color grading and successfully eliminate color casts from any video file.