title: ffmpeg: How to concat audio files and add background music in a single command?
body: <p>Need to concat audio files and add background music in a single command.</p>
  
  <p>Right now I use the following commands to do so,</p>
  
  <p><strong>To concat:</strong></p>
  
  <p><code>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</code></p>
  
  <p><strong>To add background music:</strong></p>
  
  <p><code>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</code></p>
  
  <p>But his process is a quite time-consuming process as every time the file read/write happening to the output.</p>
  
  <p>Is there a way I can merge these two above commands to a single so that the command should be optimized.</p>