<p>pzoom is the calculated zoom value for the previous frame. It is initialized to 1 at the start of filtering. So, if total no. of frames is X, your zoom expr should be</p>

<pre><code>z='min(pzoom+(2.13-1)/X,2.13)'
</code></pre>

CC BY-SA 4.0
2020-02-27T18:03:11.457Z
Great, I think I get it now. What's the 1.5 value after the comma? I thought it was the maximum zoom ratio, but I see you're keeping it to 1.5 instead of 2.13.
JPAllard
CC BY-SA 4.0
2020-02-27T20:06:48.470Z
Typo. I forgot to correct that when I copied the original expr.
Gyan
CC BY-SA 4.0
2020-02-28T02:16:04.657Z
@JPAllard — “Great” in your comment is a nice word — what about enhancing it by accepting and upvoting this answer? (Click on the check mark and on the “up” triangle.)
MarianD
CC BY-SA 4.0
2020-02-27T17:43:00.590Z
2020-02-27T20:06:22.897Z
2020-02-27T20:06:22.897Z
Gyan
<p>I'm trying to do a smooth zoom in to the center of a 4k video over the duration of that video, so basically zooming in 2.13x so that the zoom in stops when the zoom is equivalent to an HD file (4096 / 1920 = 2.13). </p>

<p>I'm having trouble finding out how I can control the length of the zoom in effect dynamically, for different video lengths. </p>

<p>Here's the command I have so far: </p>

<p><code>ffmpeg -i "{filepath}" -vf "scale=w=(4096*4):h=(2160*4), zoompan=z='min(pzoom+0.00213,2.13)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':s=1920x1080" "{output1}"</code></p>

<p>I'm guessing I need to do a calculation on the # of input frames and adjust the pzoom ratio accordingly, but I'm unsure how the pzoom ratio actually works. </p>

<ffmpeg><zoom>
ffmpeg smooth video zoom-in to center over duration of video
JPAllard
# ffmpeg smooth video zoom-in to center over duration of video

(Asked by: username_0 on 2020-02-27)

I'm trying to do a smooth zoom in to the center of a 4k video over the duration of that video, so basically zooming in 2.13x so that the zoom in stops when the zoom is equivalent to an HD file (4096 / 1920 = 2.13).

I'm having trouble finding out how I can control the length of the zoom in effect dynamically, for different video lengths.

Here's the command I have so far:

`ffmpeg -i "{filepath}" -vf "scale=w=(4096*4):h=(2160*4), zoompan=z='min(pzoom+0.00213,2.13)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':s=1920x1080" "{output1}"`

I'm guessing I need to do a calculation on the # of input frames and adjust the pzoom ratio accordingly, but I'm unsure how the pzoom ratio actually works.

**Tags:** ffmpeg, zoom


---

## 1 answers

### Answer by username_1 on 2020-02-27. Score: 3

pzoom is the calculated zoom value for the previous frame. It is initialized to 1 at the start of filtering. So, if total no. of frames is X, your zoom expr should be
z='min(pzoom+(2.13-1)/X,2.13)'

> **Comments:**
> **username_0**: Great, I think I get it now. What's the 1.5 value after the comma? I thought it was the maximum zoom ratio, but I see you're keeping it to 1.5 instead of 2.13.  
> **username_1**: Typo. I forgot to correct that when I copied the original expr.  
> **username_2**: @username_0 — “Great” in your comment is a nice word — what about enhancing it by accepting and upvoting this answer? (Click on the check mark and on the “up” triangle.)  

---

