How to add zoom transition effects using FFmpeg to a variable number of images? 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, 

https://superuser.com/questions/1189246/ffmpeg-image-slideshow-with-zoompan-and-fade-in-out/1190199

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?
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 \
zoompan=d=(A+B)/B:fps=1/B,\ 
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 \
"zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1"