Zooming animation in FFMPEG

三世轮回 提交于 2021-02-08 23:43:28

问题


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:

  • Change the filter after pulling each frame from the buffersink (I'm not in the command line, I'm using the libraries in my software). I'm doing that already, but no for every frame, only by user request in an online application.
  • Use geq filter to "apply a generic equation to each frame".

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.


回答1:


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.



来源:https://stackoverflow.com/questions/23240841/zooming-animation-in-ffmpeg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!