FFmpeg Zoompan: How to Smoothly Zoom and Hold

This article provides a complete guide on how to use the FFmpeg zoompan filter to smoothly zoom into a video over a 10-second duration and hold the final zoomed frame. You will learn the exact mathematical expressions required for the filter, how to keep the camera centered during the zoom, and how to avoid the common jitter issues associated with this filter.

The FFmpeg Command

To achieve a smooth zoom over 10 seconds and then hold, use the following FFmpeg command. This example assumes an input video of 30 frames per second (fps), meaning 10 seconds equals 300 frames (30 fps × 10 seconds).

ffmpeg -i input.mp4 -vf "scale=iw*2:ih*2,zoompan=z='if(lte(on,300),1+0.5*(on/300),1.5)':x='iw/2-(iw/zoom)/2':y='ih/2-(ih/zoom)/2':d=1:s=1920x1080,scale=1920x1080" -c:v libx264 -pix_fmt yuv420p output.mp4

How It Works (Step-by-Step)

The zoompan filter requires precise control over the zoom factor (z) and the camera coordinates (x and y) for every frame.

1. Scaling Upfront to Prevent Jitter

2. The Zoom Expression (z)

3. Centering the Zoom (x and y)

4. Frame Rate and Resolution Control


Customizing the Script

If your video specifications differ, you can easily adjust the parameters: