我的输入文件有 5 个视频和 1 个图片。我想将所有视频合并为一个视频,同时播放视频。输出视频的布局如下:

我使用 ffmpeg 来合并视频。这是我的 ffmpeg 命令:
ffmpeg
-i C:\VID\test1.mp4
-i C:\VID\test2.mp4
-i C:\VID\test3.mp4
-i C:\VID\test4.mp4
-i C:\VID\test5.mp4
-i C:\VID\background.jpg
-filter_complex
" nullsrc=size=1280x720 [base];
[0] setpts=PTS-STARTPTS, scale=560x360 [video0];
[1] setpts=PTS-STARTPTS, scale=280x180 [video1];
[2] setpts=PTS-STARTPTS, scale=280x180 [video2];
[3] setpts=PTS-STARTPTS, scale=280x180 [video3];
[4] setpts=PTS-STARTPTS, scale=280x180 [video4];
[5:v] scale=700x700 [image];
[base][video0] overlay=shortest=1 [tmp1];
[tmp1][video1] overlay=shortest=1:y=360 [tmp2];
[tmp2][video2] overlay=shortest=1:x=280:y=360 [tmp3];
[tmp3][video3] overlay=shortest=1:y=540 [tmp4];
[tmp4][video4] overlay=shortest=1:x=280:y=540 [tmp5];
[tmp5][image] overlay=570:10:enable='between(t,0,30)'"
-t 30 -c:v libx264 output.mkv
Run Code Online (Sandbox Code Playgroud)
输出视频布局工作正常,但输出视频中没有音频。我希望每个视频的所有音频都将保留在输出视频上。一起同时播放音频。我正在使用此链接上的教程:使用多个输入视频创建马赛克 感谢您的阅读
您可以使用amix或amerge音频过滤器。假设每个 MP4 输入文件还包含音频:
ffmpeg
-i C:\VID\test1.mp4
-i C:\VID\test2.mp4
-i C:\VID\test3.mp4
-i C:\VID\test4.mp4
-i C:\VID\test5.mp4
-i C:\VID\background.jpg
-filter_complex
"nullsrc=size=1280x720 [base];
[0] setpts=PTS-STARTPTS, scale=560x360 [video0];
[1] setpts=PTS-STARTPTS, scale=280x180 [video1];
[2] setpts=PTS-STARTPTS, scale=280x180 [video2];
[3] setpts=PTS-STARTPTS, scale=280x180 [video3];
[4] setpts=PTS-STARTPTS, scale=280x180 [video4];
[5:v] scale=700x700 [image];
[base][video0] overlay=shortest=1 [tmp1];
[tmp1][video1] overlay=shortest=1:y=360 [tmp2];
[tmp2][video2] overlay=shortest=1:x=280:y=360 [tmp3];
[tmp3][video3] overlay=shortest=1:y=540 [tmp4];
[tmp4][video4] overlay=shortest=1:x=280:y=540 [tmp5];
[tmp5][image] overlay=570:10:enable='between(t,0,30)'[v];
[0:a][1:a][2:a][3:a][4:a]amix=inputs=5[a]"
-map "[v]" -map "[a]" -t 30 -c:v libx264 output.mkv
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2337 次 |
| 最近记录: |