How to Use the FFmpeg Colorbalance Filter
This article provides a quick guide on how to use the
colorbalance filter in FFmpeg to adjust the primary colors
of your video files. You will learn the syntax of the filter, understand
how its parameters control shadows, midtones, and highlights, and view
practical command-line examples to help you color-correct or stylize
your video footage.
Understanding the Colorbalance Parameters
The colorbalance filter allows you to adjust the balance
of red, green, and blue (RGB) colors in three distinct tonal ranges of
an image: shadows (dark areas),
midtones (medium-gray areas), and
highlights (bright areas).
The filter uses specific variables for each tonal range and color.
Each variable accepts a decimal value between -1.0 and
1.0, where 0 is the default (no change).
Positive values increase a color, while negative values increase its
complementary color (e.g., reducing red increases cyan).
Shadows (s)
rs(Red Shadows): Adjusts red/cyan in dark areas.gs(Green Shadows): Adjusts green/magenta in dark areas.bs(Blue Shadows): Adjusts blue/yellow in dark areas.
Midtones (m)
rm(Red Midtones): Adjusts red/cyan in midtone areas.gm(Green Midtones): Adjusts green/magenta in midtone areas.bm(Blue Midtones): Adjusts blue/yellow in midtone areas.
Highlights (h)
rh(Red Highlights): Adjusts red/cyan in bright areas.gh(Green Highlights): Adjusts green/magenta in bright areas.bh(Blue Highlights): Adjusts blue/yellow in bright areas.
Practical Examples
To apply the filter, use the -vf (video filter) flag in
your FFmpeg command.
1. Warming Up a Video
To give your video a warmer, golden-hour look, you can increase the red and decrease the blue (which adds yellow) 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.mp42. Cooling Down a Video
To achieve a cold, blue, cinematic tone, increase the blue levels and slightly decrease the red levels in the midtones and shadows.
ffmpeg -i input.mp4 -vf "colorbalance=bm=0.2:bs=0.1:rm=-0.1" -c:a copy output.mp43. Removing a Green Color Cast
If your footage has an unwanted green tint (often caused by fluorescent lighting), you can correct it by lowering the green levels in the midtones.
ffmpeg -i input.mp4 -vf "colorbalance=gm=-0.15" -c:a copy output.mp44. Creating a Stylized Teal and Orange Look
To create a popular Hollywood color grade, push the shadows toward cyan (decrease red) and the midtones/highlights toward orange (increase red, decrease blue).
ffmpeg -i input.mp4 -vf "colorbalance=rs=-0.15:bs=0.1:rm=0.2:bm=-0.1:rh=0.1" -c:a copy output.mp4