FFMPEG-以指定的时间间隔在视频上叠加多路视频 [英] FFMPEG - Overlay multipe videos over video at specified interval of time

查看:246
本文介绍了FFMPEG-以指定的时间间隔在视频上叠加多路视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在指定的时间间隔内将多个视频覆盖在单个视频上.

I want to overlay multiple videos over a single video at specified interval of time.

尝试了不同的解决方案,但它不能作为我的方面工作

have tried with different solution but it will not work as i aspect

我正在使用以下命令在视频上叠加视频

i am use below command to overlay video over video

String[] cmdWorking3 = new String[]{"-i",yourRealPath,"-i",gifVideoFile1,"-i",gifVideoFile2,"-i",gifVideoFile3,
                "-filter_complex",
                "[0][1]overlay=100:100:enable='between(t,0,2)'[v1];" +
                        "[v1][2]overlay=130:130:enable='between(t,0,2)'[v2];" +
                        "[v2][3]overlay=150:150:enable='between(t,5,6)'[v3];",
                "-map","[v3]","-map" ,"0:a",
                "-preset", "ultrafast", filePath};

使用上述命令,前两个视频可以正常运行,但最后一个将无法启用

by using above command first two video completely works fine but last one will not enable

//工作完美

 String[] cmdWorking11 = new String[]
                {"-i",
                        yourRealPath,
                        "-i",
                        gifVideoFile1,
                        "-i",
                        gifVideoFile2,
                        "-i",
                        gifVideoFile3,
                        "-i",
                        gifVideoFile4,

                        "-filter_complex",

                        "[1]setpts=PTS+3/TB[1d];" +
                        "[2]setpts=PTS+7/TB[2d];" +
                        "[3]setpts=PTS+10/TB[3d];" +

                        "[0][1]overlay=100:100:enable='between(t,0,2)'[v1];" +
                        "[v1][1d]overlay=130:130:enable='between(t,3,6)'[v2];" +
                        "[v2][2d]overlay=130:130:enable='between(t,7,9)'[v3];" +
                        "[v3][3d]overlay=150:150:enable='between(t,10,13)'[v4];" +

                        "[1]asetpts=PTS+3/TB[1ad];" +
                        "[2]asetpts=PTS+7/TB[2ad];" +
                        "[3]asetpts=PTS+10/TB[3ad];" +
                        "[0:a][1ad][2ad][3ad]amix=4[a]",

                        "-map", "[v4]", "-map", "[a]", "-ac", "5",

                        "-preset",
                        "ultrafast",

                        filePath};

上面的命令完全可以正常工作,但是重叠视频中的音频消失了,请您帮我解决这个问题.

Above command is perfectly works fine but audio from the overlapped video is gone,can you please help me to solve this issue.

主视频时间持续时间约为 00:15秒,所有重叠视频均约为3秒.

main Video time Duration is about 00:15 second and all overlay videos are about 3 second.

非常感谢您提前提供帮助.

it would be great to helping out to solve this issue,Thanks in advance.

推荐答案

您需要延迟第3个重叠视频才能在重叠时开始播放.

You need to delay your 3rd overlay video to start at the time of overlay.

String[] cmdWorking3 = new String[]{"-i",yourRealPath,"-i",gifVideoFile1,"-i",gifVideoFile2,"-i",gifVideoFile3,
                "-filter_complex",
                "[3]setpts=PTS+5/TB[3d];" + 
                "[0][1]overlay=100:100:enable='between(t,0,2)'[v1];" +
                        "[v1][2]overlay=130:130:enable='between(t,0,2)'[v2];" +
                        "[v2][3d]overlay=150:150:enable='between(t,5,6)'[v3]",
                "-map","[v3]","-map" ,"0:a",
                "-preset", "ultrafast", filePath};


要保持音频效果,请在filter_complex中添加


To keep audio as well, include in filter_complex

          [1]adelay=3000|3000[1ad];
          [2]adelay=7000|7000[2ad];
          [3]adelay=10000|10000[3ad];
          [0:a][1ad][2ad][3ad]amix=5[a]

-map '[a]' -ac 2

这篇关于FFMPEG-以指定的时间间隔在视频上叠加多路视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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