5

I am trying to join multiple audio files in ffmpeg. I am using the following command:

 ffmpeg -f concat -i myfile.txt -c copy output.mp3

Where myfile.txt contains audio file paths. I am able to join the mp3 audio, but is it possible to join together audio of another format (like avi, wav, m4a, etc.)?

4
  • From the concat demuxer documentation: "All input files must have the same streams (same codecs, same time base, etc)."
    – llogan
    Sep 10 '14 at 16:01
  • @Amit Chandra- you possibly mean "join" not "merge"? Join would put them one after another. Merge would "mix" streams together. What exactly do you want to achieve?
    – Rajib
    Sep 11 '14 at 15:51
  • @Rajib I want to join audios. How can i achieve that?? Sep 12 '14 at 6:30
  • As explained by @LordNeckbeard you will have to transcode and use the concat filter rather than the demuxer if your inputs have different codecs.
    – Rajib
    Sep 12 '14 at 18:10
7

Use this:

ffmpeg -i input1.wav -i input2.mp3 -i input3.aac -filter_complex 'concat=n=3:v=0:a=1[a]' -map '[a]' <encoding options> output.mp3

Here we are outputting to mp3 from 3 different audio codec inputs. You will have to input the mp3 encoding parameters. I'm assuming your input files are audio only.

Good parameters for mp3 might 256 kbps. Then use this:

-codec:a libmp3lame -b:a 256k

But this is considered wasteful for mp3 and you might want to use instead: -q:a 3

See this and also this.

1
  • 1
    You are my hero! Thanks a lot!
    – knagode
    Jun 20 '19 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.