Invert Video Colors with FFmpeg LUT Filter

This article provides a quick, step-by-step guide on how to use the FFmpeg lut filter to invert the colors of a video. You will learn the exact command-line syntax required to apply this effect, how the lookup table (LUT) filter processes color values, and how to run the command to achieve a negative film effect on your video files.

To invert the colors of a video, you can use the lutrgb filter, which allows you to manipulate the Red, Green, and Blue channels of a video individually. By setting each channel to the negval expression, FFmpeg subtracts the current pixel value from the maximum possible value (e.g., 255 in 8-bit color), effectively inverting the colors.

The Basic Command

Use the following command to invert your video’s colors:

ffmpeg -i input.mp4 -vf "format=rgb24,lutrgb=r=negval:g=negval:b=negval,format=yuv420p" output.mp4

Command Breakdown

Alternative for YUV Videos

If you prefer to work directly in the YUV color space without converting to RGB, you can invert the luma (brightness) channel using the lutyuv filter. Note that this only inverts the brightness (creating a grayscale-like negative) unless you also shift the chroma channels:

ffmpeg -i input.mp4 -vf "lutyuv=y=negval:u=negval:v=negval" output.mp4

For most standard color inversion needs, the RGB method (lutrgb) is recommended as it delivers the expected photographic negative result.