FFMPEG - Overlay multipe videos over video at spec

2019-06-28 04:57发布

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

Edit:

//Working perfect

 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.

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.

1条回答
Ridiculous、
2楼-- · 2019-06-28 05:43

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};

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]

Replace -map 0:a with -map '[a]' -ac 2

查看更多
登录 后发表回答