Still images are beautiful—but motion brings them to life. The Ken Burns effect, named after the legendary documentary filmmaker, is a technique of slowly zooming in or out on a still image while panning across it. It adds a cinematic quality to slideshows, documentaries, and presentations.
FFmpeg's zoompan filter makes this effect possible—but its syntax is notoriously cryptic. The filter uses mathematical expressions for zoom level (z), pan position (x, y), duration (d), and output size (s). Getting the expressions right requires understanding how the filter works under the hood.
This guide demystifies zoompan, with clear examples, practical tips, and a visual approach that shows you exactly how to create stunning pan-and-zoom effects.
Key takeaways
zoompanapplies pan-and-zoom to images or video.- Expressions control zoom level (
z), pan position (x,y), duration (d), and output size (s). - Zoom in with
z='min(zoom+0.01,1.5)'. - Zoom out with
z='max(zoom-0.01,0.8)'. - Pan by animating
xorywith time (t). - Combine with
xfadefor slideshows with Ken Burns on every image. - FFmpegLab's visual controls make Ken Burns effects drag-and-drop easy.
The Gap: Cinematic Motion Without a Camera
The zoompan filter has been part of FFmpeg for years, but the documentation is minimal. The official description says: "Apply Zoom & Pan effect." That's it. The parameters are listed, but there's no guidance on how to use them.
Search online, and you'll find fragmented examples—some work, some don't. Most don't explain why the expressions are written the way they are. This guide fills that gap with clear explanations and practical, tested examples.
The Symptom: "My Slideshow Feels Static"
You've created a slideshow with FFmpeg. The images are beautiful, the transitions are smooth, and the music is perfect. But something feels off—it's static. Each image just sits there, frozen. You need motion, a sense of life, a cinematic quality.
That's exactly what the Ken Burns effect provides. And with zoompan, you can add it to every image in your slideshow.
Core Concepts: What Is the Ken Burns Effect?
The Ken Burns effect is a cinematic technique that slowly moves the camera across a still image. It typically involves:
- Zoom — slowly zooming in or out on a portion of the image
- Pan — slowly moving the view from one part of the image to another
- Combination — both zooming and panning simultaneously
The effect creates the illusion of camera movement, adding depth and storytelling to static images. It's used in documentaries, slideshows, and promotional videos.
The zoompan filter in FFmpeg generates a video by extracting a moving rectangular viewport from the input image, then scaling it to the output size.
(Extracts a moving viewport and scales to output)
The zoompan Filter Syntax
The filter takes a string of parameters, each with an expression:
Parameters:
| Parameter | Description | Default |
|---|---|---|
z | Zoom factor (1.0 = no zoom, >1 = zoom in, <1 = zoom out) | 1.0 |
x | X position of the viewport center (in input pixels) | iw/2 |
y | Y position of the viewport center (in input pixels) | ih/2 |
d | Number of frames to generate | Required |
fps | Output frame rate | 25 |
s | Output size (width x height in pixels) | Input size |
Important notes:
dmust be specified—it's the number of frames to output.z,x, andyare expressions that are evaluated for each frame.- The
zoomvariable in expressions stores the previous zoom value. iwandihare input width and height.tis the current frame index (starting from 0).
Understanding Expressions in zoompan
The expressions use a simple syntax similar to FFmpeg's evaluation engine. Here are the key variables:
zoom— The previous frame's zoom value. Starts atz's initial value.t— The current frame number (starting from 0).iw— Input image width.ih— Input image height.in_w,in_h— Same asiw,ih.
Common expression patterns:
- Linear zoom —
z='min(zoom+0.01,1.5)'(zoom in slowly, max 1.5x) - Linear zoom out —
z='max(zoom-0.01,0.8)'(zoom out slowly, min 0.8x) - Eased zoom —
z='1+0.5*sin(t/30)'(oscillating zoom) - Pan right —
x='iw/2 - (iw/zoom/2) + 5*t'(moves the view center to the right) - Pan up —
y='ih/2 - (ih/zoom/2) - 5*t'(moves the view center upward)
The formula for centering the viewport:
The viewport width at a given zoom is iw / zoom. To center the viewport, the offset from the left edge is:
So the center of the viewport is at iw/2 - (iw/zoom/2).
Example 1: Zoom In
Let's create a simple zoom-in effect on an image, from 1.0x to 1.5x over 5 seconds at 25 fps (125 frames).
# Zoom in from 1.0x to 1.5x over 5 seconds ffmpeg -i image.jpg -vf "zoompan=z='min(zoom+0.01,1.5)':d=125:s=1920x1080:fps=25" -c:v libx264 -crf 18 -t 5 zoom_in.mp4
Explanation:
z='min(zoom+0.01,1.5)'— Increment zoom by 0.01 per frame, capped at 1.5.d=125— 5 seconds at 25 fps.s=1920x1080— Output size (1080p).-t 5— Truncate to 5 seconds (safety).
The viewport is centered by default (x=iw/2, y=ih/2).
Example 2: Zoom Out
Zoom out from 1.2x down to 0.8x over 5 seconds.
# Zoom out from 1.2x to 0.8x over 5 seconds ffmpeg -i image.jpg -vf "zoompan=z='1.2 - 0.4*(t/125)':d=125:s=1920x1080:fps=25" -c:v libx264 -crf 18 -t 5 zoom_out.mp4
Here we use t directly: 1.2 - 0.4*(t/125) goes from 1.2 to 0.8 linearly over 125 frames.
Example 3: Pan Across
Pan from left to right while keeping zoom constant (1.0x).
# Pan from left to right (constant zoom) ffmpeg -i image.jpg -vf "zoompan=z=1:x='iw/2 + 100*t':d=125:s=1920x1080:fps=25" -c:v libx264 -crf 18 -t 5 pan.mp4
Explanation:
z=1— No zoom.x='iw/2 + 100*t'— Move the viewport center to the right by 100 pixels per frame.ydefaults toih/2(center).
This creates a slow pan across the image. Adjust the multiplier (100) for faster/slower pan.
Example 4: Combined Zoom + Pan
Zoom in while panning to a specific area—a classic Ken Burns effect.
# Ken Burns: zoom in on the right side of the image ffmpeg -i image.jpg -vf "zoompan=z='min(zoom+0.01,1.8)':x='iw/2 - (iw/zoom/2) + 5*t':y='ih/2':d=125:s=1920x1080:fps=25" -c:v libx264 -crf 18 -t 5 kenburns_zoom_pan.mp4
This zooms in to 1.8x while panning to the right. The expression for x centers the viewport based on the current zoom, then adds a drift of 5 pixels per frame.
Example 5: Ken Burns Slideshow
Now let's apply Ken Burns to each image in a slideshow. We'll use the concat filter with trim and setpts to process each image independently.
# Slideshow with Ken Burns on each image (3 images, 3 seconds each, with crossfades) ffmpeg -loop 1 -i img1.jpg -loop 1 -i img2.jpg -loop 1 -i img3.jpg \ -filter_complex "[0:v]trim=0:3,setpts=PTS-STARTPTS,zoompan=z='min(zoom+0.02,1.5)':d=75:s=1920x1080:fps=25[v0]; \ [1:v]trim=0:3,setpts=PTS-STARTPTS,zoompan=z='max(zoom-0.02,0.8)':d=75:s=1920x1080:fps=25[v1]; \ [2:v]trim=0:3,setpts=PTS-STARTPTS,zoompan=z='min(zoom+0.015,1.4)':x='iw/2 - (iw/zoom/2) + 10*t':d=75:s=1920x1080:fps=25[v2]; \ [v0][v1]xfade=transition=fade:duration=1:offset=2[o1]; \ [o1][v2]xfade=transition=fade:duration=1:offset=5[out]" \ -map "[out]" -c:v libx264 -crf 18 -pix_fmt yuv420p slideshow_kenburns.mp4
Each image gets a different Ken Burns treatment: zoom in, zoom out, and zoom+pan. The xfade transitions create smooth crossfades between images.
Advanced: Custom Motion Paths
You can create complex motion paths by combining expressions. For example, a sinusoidal pan:
# Sinusoidal pan + zoom (ken burns with wobble) ffmpeg -i image.jpg -vf "zoompan=z='1+0.3*sin(t/20)':x='iw/2 - (iw/zoom/2) + 50*sin(t/15)':y='ih/2 - (ih/zoom/2) + 50*cos(t/20)':d=200:s=1920x1080:fps=25" -c:v libx264 -crf 18 -t 8 wobble.mp4
This creates a gentle oscillating pan with varying zoom, giving a dreamy, floating effect.
Troubleshooting Common Issues
Here are the most common issues with zoompan and how to fix them.
| Problem | Likely Cause | Fix |
|---|---|---|
| Black borders appear | Viewport moves beyond image bounds | Clamp x and y: x='max(0, min(iw - iw/zoom, x_expr))' |
| Zoom doesn't change | Expression uses zoom incorrectly |
Ensure you reference zoom variable properly, e.g., z='min(zoom+0.01,1.5)' |
| Output is still image | d missing or set to 1 |
Set d to the number of frames desired |
| Stretched video | Input aspect ratio differs from output size | Set s=iw:ih to preserve aspect ratio, or use scale after |
| Zoom jumps at start | Initial zoom value not set |
Set initial z in expression, e.g., z='1.0 + 0.5*(t/100)' |
| Motion is too fast | Multipliers too large | Reduce the increments (e.g., 0.005 instead of 0.01) |
Ken Burns Made Easy with FFmpegLab
FFmpegLab's visual slideshow builder includes built‑in Ken Burns controls that eliminate the need to write complex expressions.
How FFmpegLab Simplifies Ken Burns
- Drag and drop your images into the timeline
- Enable Ken Burns with a single toggle
- Choose zoom direction: Zoom In, Zoom Out, Pan Left/Right/Up/Down, or Custom
- Adjust speed with a slider—instant preview
- Set start and end zoom levels with simple controls
- Preview the animation in real time
- Apply to all slides or customize per slide
- Export with one click—no command line required
Here's how Ken Burns controls look in the FFmpegLab IDE:
# Generated by FFmpegLab Ken Burns Builder # Drag sliders to adjust zoom and pan — preview in real time
With FFmpegLab, you can create professional Ken Burns effects without writing a single line of code—but if you want to see what's happening under the hood, the generated FFmpeg command is always visible.
Frequently Asked Questions (FAQ)
What is the zoompan filter in FFmpeg?
The zoompan filter applies pan-and-zoom (Ken Burns) effects to a video stream. It allows you to zoom in or out on a specific area and pan across the image, creating smooth camera movement effects.
How do I create a zoom-in effect with zoompan?
Use the expression z='min(zoom+ZOOM_RATE, MAX_ZOOM)'. For example: zoompan=z='min(zoom+0.01,1.5)':d=125:s=1920x1080:fps=25. This zooms in from 1.0x to 1.5x over 5 seconds at 25 fps.
How do I create a pan effect with zoompan?
Use the x and y parameters with expressions. For example: x='iw/2 - (iw/zoom/2) + 5*t' moves the view center to the right while zooming. For a constant zoom pan, use z=1 and animate x or y.
How do I avoid black borders with zoompan?
Set the output size to match the input size (s=iw:ih or a fixed size) and use zoom expressions that don't cause the viewport to go beyond the image boundaries. You can clamp x and y to keep the viewport within bounds.
Can I use zoompan in a slideshow with transitions?
Yes. Apply zoompan to each image individually using trim and setpts, then concatenate with xfade transitions. FFmpegLab's visual slideshow builder makes this easy with built‑in Ken Burns controls.
What is the default frame rate for zoompan?
The default frame rate is 25 fps. You can change it with the fps parameter: fps=30 for 30 fps.
Final Word
The zoompan filter is one of FFmpeg's most powerful creative tools. With a few lines of expressions, you can transform static images into dynamic cinematic sequences.
Mastering zoompan requires understanding the relationship between zoom, pan, and the viewport. The key formulas are:
- Viewport size = input size / zoom
- Viewport center =
x,y - Output = viewport scaled to output size
With practice, you can create smooth zoom-ins, zoom-outs, pans, and complex motion paths. And with FFmpegLab's visual controls, you can create Ken Burns effects without writing a single line of code—just drag sliders and preview in real time.
Next time you're creating a slideshow or video, bring your images to life with Ken Burns. Your audience will feel the motion.