Adjust Image Overlay Transparency in FFmpeg

This article provides a straightforward guide on how to change the transparency (opacity) of an image overlay using FFmpeg. You will learn the exact command-line arguments and video filters required to adjust the alpha channel of an overlay image before merging it onto a background video.

To adjust the transparency of an image overlay, you must use FFmpeg’s filter_complex toolset. This process involves converting the image to a format that supports transparency (RGBA), modifying its alpha channel value, and then overlaying it onto the main video.

The Standard FFmpeg Command

The most efficient way to change overlay opacity is by using the colorchannelmixer filter. Use the following command structure:

ffmpeg -i input.mp4 -i overlay.png -filter_complex "[1:v]format=rgba,colorchannelmixer=aa=0.5[ol];[0:v][ol]overlay=10:10" output.mp4

Command Breakdown

Alternative Method: Using the LUT Filter

You can also use the lut filter to achieve the same result by multiplying the existing alpha channel value:

ffmpeg -i input.mp4 -i overlay.png -filter_complex "[1:v]format=rgba,lut=a='val*0.5'[ol];[0:v][ol]overlay=W-w-10:H-h-10" output.mp4

In this command, lut=a='val*0.5' multiplies the original alpha value of the image by 0.5. This method is particularly useful if your source image already has varying transparency levels that you want to scale down proportionally. This example also places the overlay in the bottom-right corner using W-w-10:H-h-10.