1

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.

1 Answer 1

2

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
2
  • 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
    Commented Sep 29, 2017 at 13:34
  • 1
    Commit aa26258f on Aug 27 removed that flag, after the avfilter framework was tweaked.
    – Gyan
    Commented Sep 29, 2017 at 14:23

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.