How to Adjust RGB Gains in FFmpeg colorchannelmixer
The colorchannelmixer filter in FFmpeg provides precise
control over a video's color balance by modifying the contribution of
each color channel to the final image. This guide explains how to
directly adjust the individual gain of the red, green, and blue (RGB)
channels to correct color casts, tint footage, or alter brightness per
channel using simple FFmpeg commands.
Understanding the Filter Syntax
The colorchannelmixer filter uses a matrix where output
channels are computed as a linear combination of input channels. The
parameter names represent the output channel followed by the input
channel (e.g., rr means red input to red output,
gg means green input to green output).
By default, the diagonal parameters are set to 1.0 and
all other parameters are set to 0.0:
rr=1.0(Red channel gain)gg=1.0(Green channel gain)bb=1.0(Blue channel gain)aa=1.0(Alpha/opacity gain)
To adjust the gain of a specific channel without cross-mixing colors,
you only need to modify rr, gg, or
bb.
- Values greater than 1.0 increase the intensity of that channel.
- Values between 0.0 and 1.0 decrease the intensity of that channel.
- A value of 0.0 completely removes that channel.
Modifying Individual Channels
1. Increase or Decrease Red Gain
To increase the red channel gain by 30%:
ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=1.3" -c:a copy output.mp4To decrease the red channel gain by 50%:
ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=0.5" -c:a copy output.mp42. Increase or Decrease Green Gain
To reduce green intensity to correct a green tint:
ffmpeg -i input.mp4 -vf "colorchannelmixer=gg=0.85" -c:a copy output.mp43. Increase or Decrease Blue Gain
To boost blue for a cooler tone:
ffmpeg -i input.mp4 -vf "colorchannelmixer=bb=1.25" -c:a copy output.mp4To reduce blue for a warmer look:
ffmpeg -i input.mp4 -vf "colorchannelmixer=bb=0.7" -c:a copy output.mp4Adjusting Multiple Channels Simultaneously
You can combine parameters by separating them with colons
(:). For instance, to warm up a shot by increasing red
gain, slightly lowering green, and reducing blue:
ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=1.15:gg=0.95:bb=0.8" -c:a copy output.mp4Completely Removing a Channel
To completely drop a color channel (for example, removing the green channel entirely to create a magenta/purple effect):
ffmpeg -i input.mp4 -vf "colorchannelmixer=gg=0" -c:a copy output.mp4