How can I add add zoom transition effects using FFmpeg to a variable number of images?

I am able to create video from a variable number of images but I am not sure how to add zoom in and out transition effects between images:

 ffmpeg -framerate 1/5 -i img%03d.jpeg -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

I found this,


But problem is that images are hard coded in that example and I am not sure how to make it work for a variable number of images?

  • anybody ???????? May 16, 2019 at 18:35

1 Answer 1


I originally thought I could handle this one, but I'm still new to FFmpeg and don't think I can solve this for you. Below follows what I came up with. Maybe that can help you move in the right direction. Sorry I couldn't be more helpful.

I found the following in a search:

You can make a slideshow with crossfading between the pictures, by using a combination of the zoompan and framerate filters. "A" is the duration in seconds how long each picture is shown (without the crossfade duration), and "B" is the crossfade duration in seconds.

ffmpeg -i IMG_%3d.jpg -vf \
framerate=25:interp_start=0:interp_end=255:scene=100 \
-c:v mpeg4 -maxrate 5M -q:v 2 out.mp4

From the Superuser post you link we find:

-filter_complex \
"[0:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1[v0]; \
 [1:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
 [2:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
 [3:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
 [v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p[v]" -map "[v]" -s "800x450" -t 40 ./out_fade.mp4

Looking at the syntax, it seems you'd just toss it in without the [iN]...[oN] "variables".

So try:

-filter_complex \
  • +1 for trying, I am able to make it work using this - ffmpeg -i img%03d.jpeg -i 1.mp3 -vf zoompan=z='zoom+0.002':d=25*5:s=1280x800 -pix_fmt yuv420p -c:v libx264 -t 01:05:00 out12345.mp4 ............. my next job is to add random transition for images, so don't want to keep just 1 effect, add command to your answer I added and I will accept thanks, if you know how to improve it that would be great too May 18, 2019 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.