ffmpeg动态缩小视频(压缩)或缩小到小于原始大小 [英] ffmpeg scale down video dynamically (squeeze-back) or zoompan out to smaller than original

查看:339
本文介绍了ffmpeg动态缩小视频(压缩)或缩小到小于原始大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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]; [top][bottom]overlay=shortest=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高度,然后在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][top]overlay" -vcodec libx264 out.mp4

这篇关于ffmpeg动态缩小视频(压缩)或缩小到小于原始大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆