Invert Video Luma Channel with FFmpeg lut Filter
This article explains how to invert only the luma (brightness)
channel of a video using FFmpeg’s lut filter. You will
learn the exact command-line syntax to achieve this effect, which
reverses the light and dark areas of your footage while keeping the
color (chroma) channels completely intact.
To invert only the luma channel of a YUV video, you should use the
lutyuv filter (the YUV-specific variant of the
lut filter). This allows you to manipulate the Y (luma)
channel independently of the U and V (chroma) channels.
The FFmpeg Command
Run the following command in your terminal:
ffmpeg -i input.mp4 -vf "lutyuv=y=255-val" -c:a copy output.mp4How the Filter Works
-vf "lutyuv=y=255-val": This calls the YUV Lookup Table filter.y=255-val: This is the core expression.valrepresents the original pixel value of the luma channel (which ranges from 0 to 255). By subtractingvalfrom 255, FFmpeg inverts the brightness. A black pixel (0) becomes white (255), and a white pixel (255) becomes black (0).- Chroma Channels (U and V): Because the
uandvparameters are omitted from the filter expression, they default to their original values (u=valandv=val). This ensures the colors of the video are preserved while only the luminance is inverted. -c:a copy: This stream-copies the audio without re-encoding it, saving processing time and preserving audio quality.