How to Use FFmpeg Monochrome Filter
This article provides a quick guide on how to convert color videos into black and white (monochrome) using FFmpeg. You will learn the most efficient commands to achieve this effect, including adjusting color saturation, forcing a grayscale pixel format, and using the color channel mixer for custom monochrome results.
Method 1: Using the Hue Filter (Recommended)
The easiest way to make a video monochrome without changing the
underlying pixel format is by setting the saturation to zero using the
hue filter. This preserves compatibility with most video
players while stripping all color.
Use the following command:
ffmpeg -i input.mp4 -vf "hue=s=0" output.mp4-i input.mp4: Specifies your input video file.-vf "hue=s=0": Applies the video filter (-vf) that sets saturation (s) to0.
Method 2: Using the Format Filter (Grayscale Conversion)
If you want to convert the video’s actual color space to grayscale,
use the format filter. This method physically removes the
color channels, which can significantly reduce the final file size.
Use the following command:
ffmpeg -i input.mp4 -vf "format=gray" output.mp4-vf "format=gray": Converts the pixel format of the video to grayscale (yuv400por equivalent).
Method 3: Using the Color Channel Mixer (Artistic Control)
For a highly customized monochrome look, you can use the
colorchannelmixer filter. This allows you to control how
much of the red, green, and blue channels contribute to the final
grayscale image, similar to black-and-white lens filters in
photography.
To create a balanced monochrome mix, use this command:
ffmpeg -i input.mp4 -vf "colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3" output.mp4- The values
.3:.4:.3represent the contribution ratio of the Red, Green, and Blue channels respectively for each output channel. Adjusting these numbers lets you make specific colors (like red skies or green foliage) brighter or darker in the monochrome output.