Fade In and Out an Image Overlay in FFmpeg

This article explains how to apply fade-in and fade-out transition effects to an image overlaying a video using FFmpeg. By utilizing FFmpeg’s complex filtergraph, you will learn how to manipulate the alpha channel of an image to smoothly transition it on and off-screen at specific timestamps.

To apply a fade-in and fade-out effect to an image overlay, you must apply the fade filter to the image input before combining it with the background video using the overlay filter. Crucially, the fade filter must target the alpha (transparency) channel of the image.

Here is the standard FFmpeg command to achieve this:

ffmpeg -i background.mp4 -loop 1 -i overlay.png -filter_complex "[1:v]format=rgba,fade=in:st=1:d=1:alpha=1,fade=out:st=5:d=1:alpha=1[over];[0:v][over]overlay=x=10:y=10:shortest=1" -c:a copy output.mp4

Command Breakdown