Convert Video to Grayscale using FFmpeg lutyuv

Converting a video to grayscale is a common video editing task that can be easily achieved using FFmpeg. This article provides a quick and direct guide on how to use the lutyuv filter to set the U and V chrominance channels to 128, effectively removing all color data from your video while preserving the luminance channel.

To convert a video to black and white (grayscale) using the YUV color space, you need to strip the color (chrominance) information while keeping the brightness (luminance) intact. In the YUV color model, the Y channel represents luminance, while the U and V channels represent color. Setting both U and V to their neutral midpoint value of 128 in an 8-bit color space removes all color, resulting in a grayscale image.

The FFmpeg Command

Use the following command to apply the lutyuv filter and set the U and V channels to 128:

ffmpeg -i input.mp4 -vf "lutyuv=u=128:v=128" -c:a copy output.mp4

Command Breakdown

This method is highly efficient because it directly manipulates the pixel values of the color channels, making it one of the fastest ways to desaturate a video in FFmpeg.