Creating an FFmpeg image slideshow with zoompan and fade in/out

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.

MLT / MELT

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.

MoviePy

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.