[FFmpeg-user] FFMPEG Image overlay Fade in and out on Video not working properly, ,

Moritz Barsnick barsnick at gmx.net
Mon Aug 24 13:35:49 CEST 2015


On Mon, Aug 24, 2015 at 02:30:11 -0700, ankur456799 wrote:
> hi i have a video around 30 second and i want to set overlay image between 5
> - 10 second only and play remaining video as per as... but i have an issue
> the video start with black screen and fade in on 5th second and play well
> upto 10 second and fade out to black after 10 second and whole video is
> black screen upto 30 second
> 
> -i input.mp4  -i 34232944.png -filter_complex " [0:v][1:v]
> overlay=0:0:enable='between(t,5,10)',fade=t=in:st=5:d=1,
> fade=t=out:st=10:d=1  '" -c:v libx264 -crf 23 output.mp4

With "overlay[...],fade[...],fade[...]", you're appying the fading to the
whole video and not just the overlay. It's a filter chain, you see, and
the fade filters are chained behind the overlay.

You will want to do something like adding "-loop 1" before the overlay
image, and then using a filter like this:

  -filter_complex "[1:v]fade=t=in:st=5:d=1,fade=t=out:st=10:d=1[over];[0:v][over]overlay=0:0"

(First creates an in+out-faded version of the overlay image as
"[over]", then overlays. "Works for me (TM)".)

Moritz


More information about the ffmpeg-user mailing list