How to zoom out and pan on a picture | Zooming out photo video effect

Published: 29 August 2022
on channel: The FFMPEG guy
1,231
36

Today, we show how to zoom out and pan onto a picture. Zooming and panning allows to focus attention on a particular part of a photo, often at the center, but not always. All parameters used can be of course fully customized to suit your needs.

EXAMPLES
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
❶ Zooming out & panning from the top left of the picture (default)
→ ffmpeg -loop 1 -i input.jpg -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0022))':d=300:s=hd1080" -t 10 -pix_fmt yuv420p output01.mp4

with:
* -loop 1 -i = Creates a video loop …
* input.jpg = … with picture “input.jpg”…
* -t 10 = … that lasts 10 seconds…
* -vf = Starts now a video filter (vf)…
* zoomspan = … calling «zoompan» to create a zoom and pan video effect.
* z = … where the zoom value (z)…
* if(lte(zoom,1.0) = At start (default zoom = 1.0), so…
* 1.5 = … initializes the zoom factor at 1.5…
* max(1.001,zoom-0.0022)) = … then decreases the zoom by 0.0022 each time until it reaches 1.001.
* d=300 = Sets the effect to last 300 frames (10s)…
* s=hd1080 = … and the output to be 1080 Full HD.
* -pix_fmt yuv420p = Sets the Pixel format to yuv420p (for compatibility with Windows in my case)…
* output01.mp4 = … and outputs the result to “output01.mp4”

Panning and zooming in different directions is just a matter now of playing with the x and y values, like we will quickly show in the following 4 examples

❷ Zooming out & panning from the top right of the picture
→ ffmpeg -loop 1 -i input.jpg -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0028))':x='if(eq(x,0),0.5*iw,max(1,iw/zoom/2))':d=300:s=hd1080" -t 10 -pix_fmt yuv420p output02.mp4

with:
* x='if(eq(x,0),0.5*iw,max(1,iw/zoom/2))' = Decreases «x» horizontal position value by a zoom factor until it reaches 1. Note: iw = input width

❸ Zooming out & panning from the bottom left of the picture
→ ffmpeg -loop 1 -i input.jpg -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0024))':y=ih:d=300:s=hd1080" -t 10 -pix_fmt yuv420p output03.mp4

with:
* y=ih = Sets «y» vertical position value to video height (ih)

❹ Zooming out & panning from the bottom right of the picture
→ ffmpeg -loop 1 -i input.jpg -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0023))':x='if(eq(x,0),0.5*iw,max(1,iw/zoom/2))':y='if(eq(y,0),0.5*ih,max(1,ih/zoom/2))':d=300:s=hd1080" -t 10 -pix_fmt yuv420p output04.mp4

with:
* x='if(eq(x,0),0.5*iw,max(1,iw/zoom/2))' = Decreases «x» horizontal position value by a zoom factor.
* y='if(eq(y,0),0.5*ih,max(1,ih/zoom/2))' = Decreases «y» vertical position value by a zoom factor.

❺ Zooming out & panning from the center of the picture
→ ffmpeg -loop 1 -i input.jpg -vf zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0023))':x='max(1,iw/2-(iw/zoom/2))':y='max(1,ih/2-(ih/zoom/2))':d=300:s=hd1080' -t 10 -pix_fmt yuv420p output05.mp4

with:
* x='max(1,iw/2-(iw/zoom/2))' = Sets «x» horizontal position for zoomed out video to be centered.
* y='max(1,ih/2-(ih/zoom/2))' = Sets «y» vertical position for zoomed out video to be centered.

ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Catch up with the FFMPEG guy Channel
   • ALL THE VIDEOS FROM THE CHANNEL  
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
MUSIC
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Trips - Topher Mohr and Alex Elena
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
An FFMPEG question?
Ask the FFMPEG guy
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ


Watch video How to zoom out and pan on a picture | Zooming out photo video effect online without registration, duration hours minute second in high quality. This video was added by user The FFMPEG guy 29 August 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,231 once and liked it 36 people.