Based on the answer of @Timbo White:
Here is the way to zoom out. That I found here.
Unfortunately I do not know how to stop the loop of the zoom in zoom out. This is due to the if
but I did take the time to search, without this one I think the zoom start from 1 and not from %maxzoom%
(cf below).
A lot info are present in the docs - (not for zoom out).
Here a simple example in batch language:
This is creating with a duration
of 100
The difference are not so clear but you can see it (I think I should have choose other values for an example ...)
- Example 1 zoom in and out
- Example 2 zoom in and out
- Example 3 zoom in and out
set speed=0.02
set maxzoom=2
set /a out=1
:: Zoom in
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='min(zoom+%speed%,%maxzoom%)':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_in_%out%.mp4
:: Zoom out
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='if(lte(zoom, 1),%maxzoom%,max(zoom-%speed%,1))':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_out_%out%.mp4
:: -------------------------------------
set speed=0.02
set maxzoom=4
set /a out+=1
:: Zoom in
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='min(zoom+%speed%,%maxzoom%)':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_in_%out%.mp4
:: Zoom out
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='if(lte(zoom,1),%maxzoom%,max(1,zoom-%speed%))':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_out_%out%.mp4
:: -------------------------------------
set speed=0.04
set maxzoom=4
set /a out+=1
:: Zoom in
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='min(zoom+%speed%,%maxzoom%)':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_in_%out%.mp4
:: Zoom out
ffmpeg -r 24 -i ff.png -filter_complex "scale=-2:%maxzoom%*ih,zoompan=z='if(lte(zoom,1),%maxzoom%,max(1,zoom-%speed%))':d=100:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'",scale=-2:ih -y -shortest -c:v libx264 Zoom_out_%out%.mp4
- Example 1 speed 0.02 maxzoom 2
- Example 2 speed 0.02 maxzoom 4
- Example 3 speed 0.04 maxzoom 4
ffmpeg -r 25 -i LVjYi.jpg -filter_complex "scale=-6:6*ih,zoompan=z='min(zoom+0.0099,1.5)':d=125:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)',scale=-2:720" -y -shortest -c:v libx264 image_output.mp4
is working for me