2

I am trying to cross-fade multiple images. I found some helpful piece of code in this superuser thread. So far I am stuck at this point:

ffmpeg -loop 1 -i img0.jpg -loop 1 -i img1.jpg -i img2.jpg -f lavfi -i color=black \
-filter_complex "\
[0:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=out:st=3:d=0.25:alpha=1[va0]; \
[1:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=in:st=3:d=0.25:alpha=1,fade=t=out:st=6:d=0.25:alpha=1[va1]; \
[2:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=in:st=6:d=0.25:alpha=1[va2]; \
[3:v]scale=480x320,trim=duration=9[over0];\
[over0][va0]overlay[over1]; \
[over1][va1]overlay=format=yuv420[over2]; \
[over2][va2]overlay=format=yuv420[outv]" \
-c:v libx264 -map [outv] -y -t 9 outcross.mp4

After the 2nd clip it fades to black. It seem to have missed something.

I am still a newbie to FFmpeg so I am not too familiar on doing multiple operations.

nik1337
  • 21
  • 1
  • 3

2 Answers2

0

You have missed a -loop 1 for the third image.

ffmpeg -loop 1 -i img0.jpg -loop 1 -i img1.jpg -loop 1 -i img2.jpg -f lavfi -i color=black -filter_complex "\
[0:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=out:st=3:d=0.25:alpha=1[va0]; \
[1:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=in:st=3:d=0.25:alpha=1,fade=t=out:st=6:d=0.25:alpha=1[va1]; \
[2:v]scale=480x320,format=pix_fmts=yuva420p,fade=t=in:st=6:d=0.25:alpha=1[va2]; \
[3:v]scale=480x320,trim=duration=9[over0];\
[over0][va0]overlay[over1]; \
[over1][va1]overlay=format=yuv420[over2]; \
[over2][va2]overlay=format=yuv420[outv]" -c:v libx264 -map [outv] -y -t 9 outcross.mp4

Also see here for a different approach.

Chamath
  • 512
  • 5
  • 18
-1

It can be done with the framerate filter: https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence#Slideshow_with_crossfading_between_the_pictures

Michael
  • 133
  • 1
  • 7
  • Welcome to Super User! On this Q&A site we try to provide [good answers](https://superuser.com/help/how-to-answer) to questions people post. A part of this is including the answer in your post, [instead of simply providing a link to another page that might answer the question](https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers/8259#8259). Please edit your answer to include the actual solution to the posted question. Refer to [How to reference material written by others](https://superuser.com/help/referencing) for help. – Cas Nov 15 '16 at 10:33