Fix Green Color Cast in Video with FFmpeg

A green color cast can ruin otherwise good video footage, often caused by incorrect white balance settings or fluorescent lighting. This guide demonstrates how to neutralize and correct an unwanted green tint using FFmpeg's built-in colorbalance filter. By making targeted adjustments to shadows, midtones, and highlights, you can restore natural color tones to your video without degrading overall quality.

Understanding the colorbalance Filter

The FFmpeg colorbalance filter adjusts the intensity of primary colors (Red, Green, and Blue) across three distinct tonal ranges:

  • Shadows: rs (red), gs (green), bs (blue)
  • Midtones: rm (red), gm (green), bm (blue)
  • Highlights: rh (red), gh (green), bh (blue)

Values range from -1.0 to 1.0. A negative value reduces the presence of that color, while a positive value increases it. A value of 0 leaves the channel unchanged.

Reducing Green Across Tonal Ranges

The most direct way to eliminate a green cast is to decrease the green component. Most color casts are predominantly visible in the midtones (skin tones, backgrounds), with minor spillover into shadows and highlights.

Run the following command to apply a basic green reduction:

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

In this command:

  • gm=-0.15 applies a moderate reduction of green in the midtones.
  • gs=-0.05 lightly removes green from dark shadow areas.
  • gh=-0.05 prevents bright areas and whites from appearing greenish.
  • -c:a copy copies the audio stream directly without re-encoding.

Counterbalancing with Magenta

In color theory, the complementary (opposite) color to green is magenta, which is a mix of red and blue. If simply reducing the green values makes the image appear too dark or desaturated, you can simultaneously boost red and blue:

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

This subtracts green while adding slight amounts of red and blue in the midtones, effectively introducing magenta to neutralize stubborn green casts while preserving image brightness.

Previewing Adjustments in Real Time

Encoding an entire file repeatedly to check minor color tweaks is time-consuming. You can preview adjustments in real time using ffplay:

ffplay -i input.mp4 -vf "colorbalance=gm=-0.12:gs=-0.04:gh=-0.04"

Adjust the values in small increments (steps of 0.02 to 0.05) until the colors look balanced, then apply those finalized parameters to your ffmpeg command.