Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg: concat multiple videos, some with audio, some without

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

and I get the output error:

    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.

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.

like image 603
Tommy Adeniyi Avatar asked Sep 05 '17 14:09

Tommy Adeniyi


1 Answers

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.

Use

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
like image 129
Gyan Avatar answered Nov 13 '22 23:11

Gyan