Invert Video Colors Using FFmpeg LUT Filter

This article explains how to invert the colors of a video using the FFmpeg lut (Look-Up Table) filter. It covers the core command syntax, how the negval expression works across video channels, and how to execute the inversion reliably regardless of your video's underlying pixel format.

The Basic Inversion Command

The simplest way to invert video colors in FFmpeg is to apply the lut filter and set each color component to negval. The negval constant automatically calculates the inverted value for each pixel using the formula maxval + minval - val.

Run the following command in your terminal:

ffmpeg -i input.mp4 -vf "lut=c0=negval:c1=negval:c2=negval" -c:a copy output.mp4

In this command:

  • -i input.mp4 specifies the source video file.
  • -vf applies the video filter graph.
  • lut=c0=negval:c1=negval:c2=negval instructs FFmpeg to invert channel 0, channel 1, and channel 2.
  • -c:a copy copies the existing audio stream without re-encoding to preserve quality and speed up processing.
  • output.mp4 defines the destination file.

Inverting RGB Color Channels Explicitly

If you are working with an RGB workflow, or want to guarantee the inversion behaves according to RGB primary colors, use the lutrgb variant. This filter automatically handles the color space conversion if the source is in YUV format:

ffmpeg -i input.mp4 -vf "lutrgb=r=negval:g=negval:b=negval" -c:a copy output.mp4

Alternatively, you can write the arithmetic operation explicitly using the maximum 8-bit color value (255):

ffmpeg -i input.mp4 -vf "lutrgb=r=255-val:g=255-val:b=255-val" -c:a copy output.mp4

Inverting YUV Channels Explicitly

Most common video containers (such as standard MP4 or MKV files) store video in the YUV color space (such as yuv420p). If you prefer to stay natively in YUV without RGB conversion, use the lutyuv filter:

ffmpeg -i input.mp4 -vf "lutyuv=y=negval:u=negval:v=negval" -c:a copy output.mp4
  • y=negval inverts the luminance (brightness), turning light areas dark and dark areas light.
  • u=negval and v=negval invert the chrominance (color difference) components, shifting colors to their complementary hues.

If you only want to invert the brightness while keeping original color hues intact, invert only the luminance channel:

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