FFmpeg Overlay PNG with Transparency Over Time

This article explains how to overlay a transparent PNG image onto a video and dynamically control its opacity over time using FFmpeg. You will learn the exact command-line syntax needed to fade a logo or watermark in and out, apply constant custom transparency, or create advanced pulsing opacity effects using FFmpeg’s powerful filtering tools.

Method 1: Fading a PNG In and Out (Time-Based Opacity)

To make a transparent PNG fade in at a specific time and fade out later, you can combine the fade filter (targeting the alpha channel) with the overlay filter inside a filter_complex graph.

Use the following command:

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

How This Command Works:


Method 2: Applying a Constant Custom Transparency

If you want the PNG overlay to have a fixed, semi-transparent opacity (for example, 50% opacity) throughout the entire video, you can use the colorchannelmixer filter to adjust the alpha channel.

Use this command:

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

How This Command Works:


Method 3: Advanced Dynamic Transparency (Pulsing Effect)

For advanced scenarios where transparency needs to fluctuate continuously over time (such as a pulsing watermark), you can pass mathematical expressions using the time variable (t) to the colorchannelmixer filter.

Use this command to create a pulsing opacity effect:

ffmpeg -i input.mp4 -loop 1 -i logo.png -filter_complex \
"[1:v]format=rgba,colorchannelmixer=aa='0.5+0.5*sin(2*PI*t/3)'[logo]; \
 [0:v][logo]overlay=10:10:shortest=1" \
-c:a copy output.mp4

How This Command Works: