[FFmpeg-user] Please release me from despair: multiple overlay images with fade in + out

Stefano Sabatini stefasab at gmail.com
Wed Jan 21 11:26:11 CET 2015


On date Wednesday 2015-01-21 03:23:41 +0100, Dog Film wrote:
> Hi,
> 
> I really tried hard, I did not succeed, so I am asking here, if it is
> possible at all and if yes, how to do it...
> 
> ok, I would like to generate a movie with several images overlayed,
> like one image at a time, but the images are changing. So essentially
> like an image sequence which is overlayed on top of a video. Imagine
> slides overlayed  on the video of a speaker.
> 
> I found several ways of doing quite complex overlays, however the
> resulting video would look much nicer if the image overlays had a fade
> in and fade out.
> 
> This way I made the overlays without fades:
> 
> # WORKS: A LITTLE SUCCESS! THIS SHOWS ALL PIC_x IN A SEQUENCE, BUT NO
> FADE IN OR OUT
> FILENAME=${DIR_OUT}Lecture-16-Overlay-Fade-Trans-04.mov
> ${FFMPEG} -y -i ${VID_A} -i ${png_1} -i ${png_2} -i ${png_3} -i
> ${png_4} -i ${png_5} -i ${png_6} -filter_complex "
> [0:v][1:v] overlay=10:10:enable='between(t,2,4)' [tmp];
> [tmp][2:v] overlay=30:30:enable='between(t,6,8)' [tmp];
> [tmp][3:v] overlay=50:50:enable='between(t,10,12)' [tmp];
> [tmp][4:v] overlay=70:70:enable='between(t,14,16)' [tmp];
> [tmp][5:v] overlay=90:90:enable='between(t,18,20)' [tmp];
> [tmp][6:v] overlay=120:120:enable='between(t,22,24)' " ${FILENAME}
> 
> But I can not find a way to apply a fade-in and fade-out to each of
> these images. The filter syntax just kills me, sorry.
> 
> Finally, I 'hardcoded' the fades and generated movies, like this:
> 
>  for png in $DIR_SLIDE*.png
>  do
>      # ${FFMPEG} -y -loop 1 -i $png -t 3 -c qtrle -vf 'fade=in:1:25,
> fade=out:50:25' ${png%%png}mov
>      ${FFMPEG} -y -loop 1 -i $png -t 3 -c png -vf 'fade=in:1:25,
> fade=out:50:25' ${png%%png}mov
>  done
> 
> I found this extra step not a perfect solution, but ok, I was sure it
> would work - BUT you know what - it did NOT. All the *.mov files have
> a fade-in and out, I checked this, but when I try to overlay them with
> the same approach as above only the first movie is shown as expected,
> it fades in and fades out, but then there is no second movie anymore.
> It "feels" like some alpha-channel had to be reset or anything like
> this, but I did not find any solution.

You have to take the input timestamps into consideration. In other
words you should verify that when you enable overlay the input is
still "playing" (that is you have frames in the corresponding
timeframe).

A probably simpler approach: you can have a single file to overlay
(containing the fading in/out image sequence) and move its overlay
position.



More information about the ffmpeg-user mailing list