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.

1 Answer 1


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

  • 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
    Feb 27, 2020 at 18:03
  • Typo. I forgot to correct that when I copied the original expr.
    – Gyan
    Feb 27, 2020 at 20:06
  • 1
    @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
    Feb 28, 2020 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.