如何在单个ffmpeg命令中将不同时间的2个视频叠加到另一个视频上? [英] How to overlay 2 videos at different time over another video in single ffmpeg command?

查看:84
本文介绍了如何在单个ffmpeg命令中将不同时间的2个视频叠加到另一个视频上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ffmpeg命令行,我想在不同的时间以不同的时间将2个不同的视频叠加到另一个(主视频)的顶部.我已使用以下命令在特定的时间和特定的时间成功地在主视频上覆盖了1个视频:

Using ffmpeg command line I want to overlay 2 different videos on top of another (main video) at different time for different duration. I have successfully overlayed 1 video over the main video at specific time and for specific duration using following command:

ffmpeg -i main.mp4 -i first.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB[a]; \
                 [0:v][a]overlay=enable=gte(t\,5):eof_action=pass[out]; \
                 [1] scale=480:270 [over]; [0][over] overlay=400:400" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4

如何修改相同的命令,以同时对两个辅助视频进行相同的操作?

How can i modify the same command to apply the same operations on two secondary videos at the same time?

推荐答案

命令的正确版本:

ffmpeg -i main.mp4 -i first.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB,scale=480:270[a]; \
                 [0:v][a]overlay=400:400:enable=gte(t\,5):eof_action=pass[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4


对于两个辅助视频,


For two secondary videos,

ffmpeg -i main.mp4 -i first.mp4 -i second.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB,scale=480:270[a]; \
                 [2:v]setpts=PTS-32/TB,scale=480:270[b]; \
                 [0:v][a]overlay=400:400:enable=gte(t\,5):eof_action=pass[out0]; \
                 [out0][b]overlay=400:400:enable=gte(t\,5):eof_action=pass[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4

您必须调整第二个叠加层的PTS,比例,位置和时间,以使其与第一个叠加层不重叠.

You'll have to adjust the PTS, scale, position and timing of 2nd overlay to see it doesn't overlap with first one.

这篇关于如何在单个ffmpeg命令中将不同时间的2个视频叠加到另一个视频上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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