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.mp4In this command:
-i input.mp4specifies the source video file.-vfapplies the video filter graph.lut=c0=negval:c1=negval:c2=negvalinstructs FFmpeg to invert channel 0, channel 1, and channel 2.-c:a copycopies the existing audio stream without re-encoding to preserve quality and speed up processing.output.mp4defines 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.mp4Alternatively, 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.mp4Inverting 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.mp4y=negvalinverts the luminance (brightness), turning light areas dark and dark areas light.u=negvalandv=negvalinvert 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