FFMPEG-将多个视频合并到一个视频中,输出视频没有音频

时间:2018-10-26 03:49:25

标签: video ffmpeg

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

我使用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

输出视频布局正常,但是输出视频中没有音频。 我希望每个视频的所有音频都保留在输出视频中。同时播放音频。 我正在此链接上使用教程:Create a mosaic out of several input videos 感谢您的阅读

1 个答案:

答案 0 :(得分:1)

您可以使用amixamerge音频过滤器。假设每个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
相关问题