dmcontador
dmcontador

Reputation: 668

Zooming animation in FFMPEG

I need to make a zooming animation for a video input.

Making a panning animation is possible with the crop filter with something like this:

"crop=320:240:max(0\\,min(iw-ow\\,n)):0"

Where the first two parameters, width and height, are fixed, and the second two parameters, accept frame number n or timestamp t as expression parameters.

But width and height are evaluated only once (and cannot use n or t), so I cannot crop a size in function of time and then apply a scale filter to the original size.

I know I can:

Both approaches seem expensive. Is there another filter or approach I could use?

Note that I'm using zeranoe FFMPEG libraries in Windows. I'd rather not develop my own filters or modify FFMPEG source.

Upvotes: 6

Views: 4942

Answers (1)

jrkt
jrkt

Reputation: 2715

You can apply a simple zoom by adding

"zoompan=z='zoom+0.001'"

to your video filters. It will, by default, zoom in to the top left corner slowly. If you want to do something a little more advanced, you can add the x and y arguments to start getting a zoom in other directions and variable speeds. An example of

"zoompan=z='zoom+0.001':x='if(gte(zoom,1.5),x,x+1)':y='y'"

would go to the top right and

"zoompan=z='zoom+0.001':y='if(gte(zoom,1.5),y,y+1)':x='x'"

would go to the bottom left.

Upvotes: 6

Related Questions