Reputation: 1260
Need to concat audio files and add background music in a single command.
Right now I use the following commands to do so,
To concat:
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4 -filter_complex '[0:0][1:0]concat=n=10:v=0:a=1[out]' -map '[out]' -strict -2 -y 10_final.mp4
To add background music:
ffmpeg -i 10_final.mp4 -i music.mp4 -filter_complex "[0:a]volume=1dB[a0];[1:a]volume=0.5[a1];[a0][a1]amerge=inputs=2[a]" -map "[a]" -ac 1 -ab 32000 -ar 22050 -strict -2 -y 10_with_music.mp4
But his process is a quite time-consuming process as every time the file read/write happening to the output.
Is there a way I can merge these two above commands to a single so that the command should be optimized.
Upvotes: 1
Views: 3944
Reputation: 93329
Use
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4
-i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4
-i music.mp4
-filter_complex '[0:0][1:0]...[9:0]concat=n=10:v=0:a=1,volume=1dB[a0];
[10]volume=0.5dB[a1];[a0][a1]amerge[a]'
-map '[a]' -strict -2 -y 10_with_music.mp4
Upvotes: 4