I've been trying FFmpeg through whatever tutorials I can find over the internet and I'm a bit puzzled as to how to combine a zoompan effect with fade in and fade out of a series of images.

A got to the following after combining bits and pieces of examples I found but it looks like the result I get is sequential and not what I thought it would be.

Any pointers to point me to the right direction would be appreciated.

ffmpeg \ 
-loop 1 -t 5 -i input/slideshow/img0001.jpeg 
-loop 1 -t 5 -i input/slideshow/img0002.jpeg \
-loop 1 -t 5 -i input/slideshow/img0003.jpeg \
-loop 1 -t 5 -i input/slideshow/img0004.jpeg \
-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 output/out_fade.mp4
  • It's not clear what you are trying to achieve versus what you actually achieved, can you clarify? A gif would be very handy!
    – bertieb
    Commented Mar 18, 2017 at 12:21
  • Hi @bertieb thanks for your reply. My goal is to create a command with an arbitrary number of pictures which will appear in sequence with a fade in and out and each one will zoom in for the time that is visible. So let's say i have 4 images like above, first one starts off the video and it's zooming out and at the end of the 5 seconds fades out while the second one fades in already zoomed in and continues with the same zoom out and so on to the third and fourth. Been messing around with it some more after I posted the question, it looks like I haven't quite grasped the ffmpeg usage
    – Kostas
    Commented Mar 18, 2017 at 12:55
  • Thank you for the clarification. It sounds like the effect would approximate a 'continuous' (albeit over different images) zoom-out if I've understood correctly?
    – bertieb
    Commented Mar 18, 2017 at 13:07
  • more or less yes, actually the ultimate goal would be to have random ways of presenting the images of the slideshow I started by trying a fadein fadeout which worked ok and moving on I tried the zoompan as well to add a bit of movement before the transition from one to the other ... maybe the next step would be to have the images sliding over the previous one.
    – Kostas
    Commented Mar 18, 2017 at 13:29
  • 1
    I am taking it step by step :) and the thing is I want to collect whatever I can do with ffmpeg because the whole thing will be set up as a web app project and it will have to be able to work through the ffmpeg cli. Could you suggest anything on the original question asked? thanks!
    – Kostas
    Commented Mar 20, 2017 at 12:33

1 Answer 1


Combining a zoom with a fade with ffmpeg

The example you gave with ffmpeg actually worked with very little modification (keeping -loop in caused a segfault: "Error in 'ffmpeg': double free or corruption (!prev): 0x0000000008dffa00").

So we have:

ffmpeg \
-t 5 -i 1.jpg \
-t 5 -i 2.jpg \
-t 5 -i 3.jpg \
-t 5 -i 4.jpg \
-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

Example Output:

zoompan and fade example

Potato quality- I need to figure out gif optimisation better! Artifacts and distortion are result of trying to get file size < 2MB and are not present in original video output- it should be enough to give you an idea of whether it fits your use-case. Images are my own.

(additional) Using varied or arbitrary transitions

added based on comments

Even with this minimal example, the filtergraph gets quite complex quite quickly, and it's tedious to change things. A different library might do better.


For example,MELT for the MLT Framework might do:

Melt was developed as a test tool for the MLT framework. It can be thought of as a powerful, if somewhat obscure, multitrack command line oriented video editor.

and is frequently suggested.


However, MoviePy (GitHub page) might suit your needs better, as it is slightly more concise and (I'd suggest) more user-friendly, insofar as a command-line video editor can be user-friendly.

You probably are most interested in the sections on compositing and transitions/effects

I suggest the above two based on my own experience of trying to crowbar in transitions with ffmpeg; it's doable and capable of producing some very decent effects, but the pain is not worth it. The script above should answer your question about a continuous zoom-out with a fade in/out.

  • I was looking for hours for that you save my life literally .
    – Salem F
    Commented Dec 2, 2017 at 21:11
  • @bertieb This effect is working fine with only Landscape video and for square & portrait Images the video is playing in landscape -t 10 -i img00.jpg -t 10 -i img01.jpg -filter_complex [0:v]zoompan=z='if(lte(zoom,1.0),1.7,max(1.001,zoom-0.0045))':d=125,fade=t=out:st=4:d=1[v0];[1:v]zoompan=z='if(lte(zoom,1.0),1.7,max(1.001,zoom-0.0045))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1];[v0][v1]concat=n=2:v=1:a=0,format=yuv420p[v] -map [v] -s 720x1280 -t 40 -preset ultrafast video25.mp4
    – Divy Soni
    Commented Apr 24, 2019 at 6:06
  • Here for zoom in and out from center : superuser.com/a/1112737/860920
    – Dorian Grv
    Commented Dec 23, 2022 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .