0

Thank you for coming here. I have three video clips (the first is 3 seconds, the second is 20 seconds, the third is 2 seconds), I connect them using the following command:

ffmpeg -i opening.mp4 -i middle.mp4 -i ending.mp4 -filter_complex "[0:v] [1:v] [2:v] concat=n=3:v=1 [v]" -map "[v]" output.mp4

Since all three videos do not have audio tracks, I do not need to include [a]. And then the day came when I needed it. I have an audio track, duration of 35 seconds(which is much larger than the output.mp4 video) and I need this audio to be connected to the whole video. 1) Do I need to crop the audio to the length that is obtained by merging all three videos? 2) Is it possible to do this with one command, or i need first have to concatetate all together with my command, and then merge video and audio track?

  • Thank you for your response and for your help. This is a very good answer to my previous question. This question is slightly different. Here I ask what to do if the sound track is bigger than the video itself. – Михаил Безуглый Sep 27 '18 at 01:46

1 Answers1

0

Use the -shortest option:

ffmpeg -i opening.mp4 -i middle.mp4 -i ending.mp4 -i music.m4a -filter_complex "[0:v] [1:v] [2:v] concat=n=3:v=1:a=0 [v]" -map "[v]" -map 3:a -shortest output.mp4

For MP4 output you can add -c:a copy if the audio input is already AAC.

llogan
  • 121,796
  • 28
  • 232
  • 243