FFMPEG zoompan filter examples

ffmpegvideo

I need to create a video with ffmpeg with various pans and zooms using the zoompan filter. I have to be able to create zoom in, zoom out, pan to, and pan from effects to all areas of the video such as: top-left, top-middle, top-right, right, bottom-right, bottom-middle, bottom-left, left, and middle. So far, I have only been able to figure out how to zoom in to a few areas, such as:

Zoom in top-left:

-vf "zoompan=z='zoom+0.001':x='if(gte(zoom,1.5),x,x-1)':y='y':d=125"

Zoom in top-right:

-vf "zoompan=z='zoom+0.001':x='if(gte(zoom,1.5),x,x+1)':y='y':d=125"

Zoom in bottom-left:

-vf "zoompan=z='min(zoom+0.0005,1.5)':y='if(gte(zoom,1.5),y,y+1)':x='x':d=125"

I have not been able to find a good resource to explain how these numbers work and how I can figure out the specific zoompan filters for all these variations.

Help????

Best Answer

The zoompan filter expressions are evaluated each frame. The variables referenced in the expressions contain the last calculated value, or the default if it's the first frame.

The value of the evaluated zoom expression represents the ratio of the resulting dimensions to the original dimensions i.e. zoom = 3 means the zoom window has a third of the width and height of the input.

x and y represent where the top-left corner of the zoom window is placed within the input image.

d is the duration in frames that the zoom is evaluated and applied.

You should, as a matter of course, specify the output framerate fps and size s of the filter (see its documentation), else the filter will apply its defaults of 25 fps and 1280x720, which may not be what you want.

For smooth zooms, you may need to upscale the image beforehand.

Related Question