<p>With loop added, you are generating a video stream from the image. Now, <code>zoom</code> is applicable within the processing loop of a single frame, and <code>pzoom</code> for video streams. Also, zoompan doesn't have timeline editing support, no <code>enable</code> won't work. So,</p>

<pre><code>ffmpeg -i $FOOTAGE -loop 1 -i $IMAGE -filter_complex \
"
[1:v]
 zoompan=
    z='if(gte(in,24),min(pzoom+1.3/18,2.3),19.3/18)'
    :x='iw/2-(iw/pzoom/2)'
    :y='ih/2-(ih/pzoom/2)'
    :d=1
    :s=500x100
[name];
[0:v][name]
  overlay=
    x=1005-250-3*n
    :y=406-50
    :enable='lte(n,173)'
" -t 7 -y  -hide_banner  out.mp4
</code></pre>

CC BY-SA 3.0
2017-09-29T13:34:45.477Z
zoompan is timeline-capable: see output of `ffmpeg -hide_banner  -h filter=zoompan` – it reads  "This filter has support for timeline through the 'enable' option.".   Besides it kind of works to me already, when I set `d=19` for the zooming part.
Serge
CC BY-SA 3.0
2017-09-29T14:23:57.783Z
Commit aa26258f on Aug 27 removed that flag, after the avfilter framework was tweaked.
Gyan
CC BY-SA 3.0
2017-09-29T12:09:51.720Z
2017-09-29T12:09:51.720Z
Gyan
<p>I am trying to animate an image position and scale on top of  background video. Moving between frames, say, 1 and 15. And scaling from frame 24 to frame 42.</p>

<p><a href="https://ffmpeg.org/ffmpeg-filters.html#overlay-1" rel="nofollow noreferrer">overlay</a> filter does its job moving the image at a time well.</p>

<p>I'm lost with the <a href="https://ffmpeg.org/ffmpeg-filters.html#zoompan" rel="nofollow noreferrer">zoompan</a> filter. Here's my current filtergraph:</p>

<pre><code>video.avi &gt;-----------------------------------&gt;|-------|
                                               |overlay|-&gt; out.mp4
image.png &gt;-&gt; scale &gt;-&gt; zoompan &gt;-&gt; zoompan &gt;-&gt;|-------|
</code></pre>

<p>Scale up the image 10 times for jitter-free zoompan. The first <em>zoompan</em> is set to <code>z=1</code> and enabled till start of zoom (frame 24). Second <em>zoompan</em> increments zoom by a step to reach from 1 to 2.3 in 18 frames (24..42). I would add third <em>zoompan</em> to keep the image at 2.3. If second one is prolonged further it starts looping the zoom-in effect. </p>

<pre><code>ffmpeg -i $FOOTAGE -loop 1 -i $IMAGE -filter_complex \
"
[1:v]
  scale=10*iw:-2
  ,zoompan=
    z=1
    :d=1
    :s=500x100
    :enable='lt(n,24)'
  ,zoompan=
    z='min(zoom+1.3/18,2.3)'
    :x='iw/2-(iw/zoom/2)'
    :y='ih/2-(ih/zoom/2)'
    :d=19
    :s=500x100
    :enable='gte( n, 24)'
[name];
[0:v][name]
  overlay=
    x = '1005 - 250 + 80 - min( 80 * n / 15, 80)'
    :y='406-50'
    :enable='lte(n,130)'
" -t 7 -y  -hide_banner out.mp4
</code></pre>

<p>How can zoom an image between certain keyframes somewhere in the middle of the sequence? I.e. zoom goes from 1 to 2.3 between frame A and frame B.</p>

<ffmpeg><animation>
How to keyframe zoompan filter in ffmpeg?
Serge
# How to keyframe zoompan filter in ffmpeg?

(Asked by: username_0 on 2017-09-29)

I am trying to animate an image position and scale on top of  background video. Moving between frames, say, 1 and 15. And scaling from frame 24 to frame 42.
overlay filter does its job moving the image at a time well.
I'm lost with the zoompan filter. Here's my current filtergraph:
video.avi >----------------------------------->|-------|
                                               |overlay|-> out.mp4
image.png >-> scale >-> zoompan >-> zoompan >->|-------|

Scale up the image 10 times for jitter-free zoompan. The first zoompan is set to z=1 and enabled till start of zoom (frame 24). Second zoompan increments zoom by a step to reach from 1 to 2.3 in 18 frames (24..42). I would add third zoompan to keep the image at 2.3. If second one is prolonged further it starts looping the zoom-in effect. 
ffmpeg -i $FOOTAGE -loop 1 -i $IMAGE -filter_complex \
"
[1:v]
  scale=10*iw:-2
  ,zoompan=
    z=1
    :d=1
    :s=500x100
    :enable='lt(n,24)'
  ,zoompan=
    z='min(zoom+1.3/18,2.3)'
    :x='iw/2-(iw/zoom/2)'
    :y='ih/2-(ih/zoom/2)'
    :d=19
    :s=500x100
    :enable='gte( n, 24)'
[name];
[0:v][name]
  overlay=
    x = '1005 - 250 + 80 - min( 80 * n / 15, 80)'
    :y='406-50'
    :enable='lte(n,130)'
" -t 7 -y  -hide_banner out.mp4

How can zoom an image between certain keyframes somewhere in the middle of the sequence? I.e. zoom goes from 1 to 2.3 between frame A and frame B.

**Tags:** ffmpeg, animation


---

## 1 answers

### Answer by username_1 on 2017-09-29. Score: 2 | Accepted answer

With loop added, you are generating a video stream from the image. Now, zoom is applicable within the processing loop of a single frame, and pzoom for video streams. Also, zoompan doesn't have timeline editing support, no enable won't work. So,
ffmpeg -i $FOOTAGE -loop 1 -i $IMAGE -filter_complex \
"
[1:v]
 zoompan=
    z='if(gte(in,24),min(pzoom+1.3/18,2.3),19.3/18)'
    :x='iw/2-(iw/pzoom/2)'
    :y='ih/2-(ih/pzoom/2)'
    :d=1
    :s=500x100
[name];
[0:v][name]
  overlay=
    x=1005-250-3*n
    :y=406-50
    :enable='lte(n,173)'
" -t 7 -y  -hide_banner  out.mp4

> **Comments:**
> **username_0**: zoompan is timeline-capable: see output of `ffmpeg -hide_banner  -h filter=zoompan` – it reads  "This filter has support for timeline through the 'enable' option.".   Besides it kind of works to me already, when I set `d=19` for the zooming part.  
> **username_1**: Commit aa26258f on Aug 27 removed that flag, after the avfilter framework was tweaked.  

---

