How to Use the FFmpeg Colorchannelmixer Filter

This article provides a practical guide on how to use the colorchannelmixer filter in FFmpeg to adjust, correct, and creative-style video color channels. You will learn the underlying mechanics of this filter, understand its parameter syntax, and explore real-world examples such as converting video to grayscale, swapping color channels, and applying custom color tints.

Understanding the Colorchannelmixer Filter

The colorchannelmixer filter allows you to modify the color profile of a video by mixing the input color channels (Red, Green, Blue, and Alpha) to produce new output channels. It acts as a 4x4 matrix multiplier where every output channel is a weighted sum of the input channels.

The filter accepts 16 parameters, grouped by the output channel they target:

Each parameter accepts a decimal value between -2.0 and 2.0. The default value for identity properties (rr, gg, bb, aa) is 1.0, while all other crosstalk parameters default to 0.0.

Practical Examples

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

1. Converting Video to Grayscale

To create a black-and-white effect, you must set the red, green, and blue output channels to receive the same ratio of input colors. A standard luminance formula uses 30% Red, 59% Green, and 11% Blue:

ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=0.3:rg=0.59:rb=0.11:gr=0.3:gg=0.59:gb=0.11:br=0.3:bg=0.59:bb=0.11" output.mp4

2. Swapping Color Channels

You can swap color channels to create artistic, surreal, or infrared-like effects. For example, to swap the Red and Blue channels:

ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=0:rb=1:br=1:bb=0" output.mp4

In this command, the output Red channel is driven entirely by the input Blue channel (rb=1), and the output Blue channel is driven entirely by the input Red channel (br=1).

3. Adjusting Color Temperature (Warm / Cool Tones)

You can use the filter to perform basic color grading. To make a video look warmer, increase the red input contribution and slightly reduce the blue input contribution:

ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=1.2:gg=1.0:bb=0.8" output.mp4

To make the video look cooler (bluer), do the opposite:

ffmpeg -i input.mp4 -vf "colorchannelmixer=rr=0.8:gg=1.0:bb=1.2" output.mp4

4. Enhancing Specific Colors

If you want to boost a specific color—for instance, making greens more vibrant in a landscape shot—you can increase the green-to-green coefficient or mix a small amount of blue into the green channel:

ffmpeg -i input.mp4 -vf "colorchannelmixer=gg=1.15:gb=0.05" output.mp4