FFmpeg Zoompan Filter Ken Burns Effect Tutorial

This guide explains how to use the FFmpeg zoompan filter to apply a dynamic Ken Burns effect—slowly zooming and panning—to a static image. You will learn the basic syntax, the mathematical formulas behind the filter’s variables, and how to execute a complete command to generate a high-quality video from a single photo.

The Basic Ken Burns Command

To create a smooth zoom towards the center of an image, use the following FFmpeg command:

ffmpeg -loop 1 -i input.jpg -vf "zoompan=z='zoom+0.0015':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=125:s=1920x1080" -c:v libx264 -t 5 -pix_fmt yuv420p output.mp4

Command Breakdown


Adjusting the Movement and Direction

You can customize the Ken Burns effect by changing the x and y equations to control where the camera pans.

Zooming into the Top-Left Corner

To zoom into the top-left corner, set both the X and Y coordinates to zero:

zoompan=z='zoom+0.0015':x=0:y=0:d=125:s=1920x1080

Zooming into the Bottom-Right Corner

To zoom into the bottom-right corner, offset the focus point using the maximum boundaries of the zoomed frame:

zoompan=z='zoom+0.0015':x='iw-(iw/zoom)':y='ih-(ih/zoom)':d=125:s=1920x1080

Pan Left-to-Right (No Zoom)

To pan across an image without changing the scale, set a constant zoom level greater than 1 (e.g., 1.5) and transition the X coordinate based on the current frame (on):

zoompan=z=1.5:x='(iw-iw/zoom)*(on/d)':y='ih/2-(ih/zoom/2)':d=125:s=1920x1080

Preventing Jitter and Shaking

The zoompan filter performs coordinate calculations using integers, which can cause the camera motion to appear shaky or jittery. To achieve a perfectly smooth Ken Burns effect, pre-scale your input image to a higher resolution before applying the zoompan filter.

Add a scale filter directly before the zoompan filter in your filtergraph:

ffmpeg -loop 1 -i input.jpg -vf "scale=3840:-1,zoompan=z='zoom+0.001':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=125:s=1920x1080" -c:v libx264 -t 5 -pix_fmt yuv420p output.mp4

In this optimized command, scale=3840:-1 upscale-sizes the image width to 3840 pixels (maintaining aspect ratio) before the zoom is calculated, which provides more pixel data for smoother fractional coordinate transitions.