video - FFMPEG - 将多个视频合并为一个视频,输出视频没有音频
问题描述
我的输入文件有 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
输出视频布局工作正常,但输出视频中没有音频。我希望每个视频的所有音频都保留在输出视频上。同时播放音频。我正在使用此链接上的教程:使用多个输入视频创建马赛克 感谢阅读
解决方案
您可以使用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
推荐阅读
- reactjs - 如何检查完全渲染的 React 子组件,包括其中的 AJAX 调用?
- r - 将 .byte 文件读入 R
- javascript - 响应式菜单未在单击时关闭
- ios - 未调用 IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken
- amazon-web-services - 具有 jenkins 构建阶段的代码管道的 AWS Cloudformation 模板
- xcode - 无法将下面的视图添加到情节提要中的标签
- azure - 来自特定文档的自定义技能的天蓝色搜索索引器的响应是:无法执行技能。WebApi 技能响应包含错误
- javascript - 在 nuxt.js 路由之后令牌未定义
- php - 在 Laravel 上读取上传的 CSV 时在每个字母之间获取未知字符
- react-native - 有没有办法在反应原生博览会中按下按钮重新加载应用程序?