Reputation: 1260
I use the following commands to concat audio-less video files to one and add audio to it,
To concat individual videos,
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -filter_complex 'concat=n=5:v=1:a=0[out]' -map '[out]' -strict -2 -y video_withoutaudio.mp4
To add audio,
ffmpeg -i video_withoutaudio.mp4 -i audio.mp4 -c:v copy -c:a aac -strict -2 video_withaudio.mp4
is there a way to combine these two commands to one?
My requirement is to optimise the commands as I have 1000+ commands taking a lot of time to complete, hoping combining these two to one will save some time.
Thanks in advance!
Upvotes: 2
Views: 4759
Reputation: 92928
Use
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -i audio.mp4
-filter_complex 'concat=n=5:v=1:a=0[out]'
-map '[out]' -map a -c:a aac -strict -2 -y video_withaudio.mp4
I assume that none of the concat videos have audio. If they do, the result will be unexpected.
Upvotes: 4