How to Use the FFmpeg Negate Filter
This article explains how to use the negate video filter
in FFmpeg to invert the colors of your videos and images. You will learn
the basic command syntax, how to apply the filter to different file
formats, and how to control whether the alpha (transparency) channel is
inverted during the process.
The negate filter in FFmpeg is a simple yet powerful
tool used to invert the color channels of a visual input, creating a
“negative” effect similar to traditional film negatives.
Basic Video Color Inversion
To invert the colors of a video file, use the video filter flag
(-vf) followed by the negate filter. Here is
the basic command:
ffmpeg -i input.mp4 -vf negate output.mp4In this command: * -i input.mp4 specifies your source
video. * -vf negate applies the color inversion filter. *
output.mp4 is the resulting inverted video.
Inverting Image Colors
The negate filter works exactly the same way for still
images. You can convert a standard image into its negative counterpart
using the following command:
ffmpeg -i input.jpg -vf negate output.jpgManaging the Alpha Channel (Transparency)
By default, the negate filter inverts all components of
the input, including the alpha (transparency) channel if one is present.
If you are working with transparent PNGs or videos with alpha channels
(like ProRes 4444) and want to keep the transparency intact while only
inverting the colors, you must disable alpha negation.
To prevent the alpha channel from being inverted, set the
negate_alpha option to 0:
ffmpeg -i input.png -vf "negate=negate_alpha=0" output.pngSetting negate_alpha=1 (or leaving it out entirely) will
invert the transparency, turning solid areas transparent and transparent
areas solid.