FFmpeg:连接多个视频,一些带有音频,有些没有 [英] FFmpeg: concat multiple videos, some with audio, some without

查看:507
本文介绍了FFmpeg:连接多个视频,一些带有音频,有些没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接第一个和最后一个没有音轨的5个视频.我已经尝试了以下命令:

I'm trying to concatenate 5 videos where the first and last have no audio track. I have tried the following command:

    ffmpeg -i 1-copyright/copyright2018640x480.mp4 -i 2-openingtitle/EOTIntroFINAL640x480.mp4 -i 3-videos/yelling.mp4 -i 4-endtitle/EOTOutroFINAL640x480.mp4 -i 5-learnabout/Niambi640.mp4 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] [3:v:0] [3:a:0] [4:v:0] [4:a:0] concat=n=5:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output_video.mp4

我得到输出错误:

    Stream specifier ':a:0' in filtergraph description [0:v:0] [0:a:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] [3:v:0] [3:a:0] [4:v:0] [4:a:0] concat=n=5:v=1:a=1 [v] [a] matches no streams.

我知道第一个和最后一个视频都没有音频,但是我不知道如何编写声明以忽略那些视频中的音轨.我尝试删除[0:a:0],但这只会引发另一个错误:

I know the first and last videos have no audio but I dont know how to write the statement to ignore the audio track in those videos. I have tried removing the [0:a:0] but that just throws another error:

   Stream specifier ':v:0' in filtergraph description [0:v:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] [3:v:0] [3:a:0] [4:v:0] [4:a:0] concat=n=5:v=1:a=1 [v] [a] matches no streams.

这没有意义,我有点迷失了.

It doesnt make sense and Im kinda lost.

推荐答案

如果还要串联音频,则所有视频输入都必须与音频流配对.如果文件本身没有音频,则可以使用哑音轨.

If you're concatenating audio as well, then all video inputs must be paired with an audio stream. If the file itself doesn't have any audio, then a dummy silent track can be used.

使用

ffmpeg -i 1-Video.mp4 -i 2-openingtitle/EOTIntroFINAL640x480.mp4
       -i 3-videos/yelling.mp4 -i 4-endtitle/EOTOutroFINAL640x480.mp4
       -i 5-learnabout/Niambi640.mp4 -f lavfi -t 0.1 -i anullsrc -filter_complex
       "[0:v:0][5:a][1:v:0][1:a:0][2:v:0][2:a:0][3:v:0][3:a:0][4:v:0][5:a] concat=n=5:v=1:a=1 [v][a]"
       -map "[v]" -map "[a]" output_video.mp4

这篇关于FFmpeg:连接多个视频,一些带有音频,有些没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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