ffmpeg 动态缩小视频(回缩)或缩放至小于原始视频 [英] ffmpeg scale down video dynamically (squeeze-back) or zoompan out to smaller than original
问题描述
我有 2 个视频,我试图将一个视频叠加在另一个视频上,然后以动画方式将其缩小,直到看起来像画中画设置.然后,几秒钟后它应该会回缩.
I have 2 videos, I'm trying to overlay one on top of the other, and have it shrink down in an animated fashion until it appears like a picture-in-picture setup. Then, after a few seconds it should scale back up.
这就是我想要实现的目标(这些将是视频,不是图像):
This is what I am trying to achieve (these would be videos, not images):
这是我能得到的最接近的结果,但至关重要的是,缩放移出"会导致(与in"相反)似乎不起作用;所以,当然,这不起作用:
This is the closest I've been able to get, but, crucially, zoompanning "out" (as opposed to "in") does not appear to work; so, of course, this does not work:
ffmpeg -i bg.mov -i top.mov -filter_complex "[0:v]zoompan=z='pzoom-0.1':d=1, setpts=PTS-STARTPTS[top];[1:v]setpts=PTS-STARTPTS+2/TB, scale=1920x1080, format=yuva420p,colorchannelmixer=aa=1.0[bottom];[顶部][底部]叠加=最短=0"-vcodec libx264 out.mp4
这可以用 ffmpeg 实现吗?
Is this achievable with ffmpeg?
推荐答案
使用带有动画的缩放过滤器,从 v4.3 开始可用.
Use the scale filter with animation, available since v4.3.
这里有一些东西可以帮助您入门.这将在 2 秒内将顶层从 480 px 高度扩展到 1080 px,然后在 2 秒内恢复到 480 px.
Here's something to get you started. This will expand the top layer from 480 px height to 1080 height in 2 seconds and then back to 480 px in 2 seconds.
ffmpeg -i bg.mov -i top.mov -filter_complex "[0:v]scale=1920x1080,setpts=PTS-STARTPTS[bg];[1:v]setpts=PTS-STARTPTS+2/TB, scale=-1:'480+600*abs(sin((t-2)*2*PI/8))':eval=frame[top];[bg][顶部]覆盖"-vcodec libx264 out.mp4
这篇关于ffmpeg 动态缩小视频(回缩)或缩放至小于原始视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!