6

I know how to make 5 second video "zooming in" effect with 1 image using zoompan.

ffmpeg -loop 1 -i image1.jpg -vf "zoompan=z='min(zoom+0.0015,1.5)':d=125" -c:v libx264 -t 5 -s "800x450" zoomin.mp4

How do I do the "zooming out" video?

tried below but none of them are working:

ffmpeg -loop 1 -i image1.jpg -vf "zoompan=z='min(zoom-0.0015,1.5)':d=125" -c:v libx264 -t 5 -s "800x450" zoomout.mp4

ffmpeg -loop 1 -i image1.jpg -vf "zoompan=z='max(1.5,zoom-0.0015)':d=125" -c:v libx264 -t 5 -s "800x450" zoomout.mp4

ffmpeg -loop 1 -i image_1.jpg -vf "zoompan=z='max(zoom-0.0015,1.5)':d=125" -c:v libx264 -t 5 -s "800x450" zoomin.mp4

2 Answers 2

13

You must first set the zoom factor, as by default it is set to 1.0. I was able to do so like this:

ffmpeg -loop 1 -i image_1.jpg -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125" -c:v libx264 -t 5 -s "800x450" zoomout.mp4

Which will start zoomed in at 1.5 and zoom out 0.0015 every iteration. Note the value 1.001 was used (any value larger than 1.0) to ensure it would not zoom out past 1.0 and reset to 1.5.

Another solution could have been to simply reverse the output of your original zoompan, but after a quick search into it, reversing video seems like a lot of effort in ffmpeg.

1
  • How can we support this for multiple concatenated images? I thought d=125 will work but there is some problem as image tends to remain there for longer than 5 sec Jul 29, 2018 at 10:41
3

Calculate the z from the frame index (on) and the duration.

on/duration will get you a percent from 0-1 that grows each frame.

1.5-on/duration*0.5 Gives you a number from 1.5-1.

All together:

ffmpeg -loop 1 -i image1.jpg -vf "zoompan=z='1.5-on/duration*0.5':d=125" -c:v libx264 -t 5 -s "800x450" zoomin.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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