Concatenating several .mp3 files into one .mp3

cat is not the right tool for this job. The MP3 format has all sorts of junk that can lurk at the front and end of the file and this needs to be strippe out. mp3wrap is what you want. It will exclude any metadata in the files and stick the audio together.

sudo apt-get install mp3wrap
mp3wrap output.mp3 *.mp3

Before you do that, run ls *.mp3 to check that they're in the correct order. When I originally wrote this answer (over six years ago!) wildcard globs apparently didn't behave well but I think they do now.

You might need to rename the files if for example, they are numbered but aren't zero-padded, {1-11}.mp3 would be sorted by 1 10 11 2 3 4 5 6 7 8 9. This can be fixed easily.


mp3wrap seems to be a decent enough solution, but when I played the resulting file, the timestamp wasn't correct. It seems like mp3wrap is best used when you're joining mp3s into a file that you know you'll want to split later.

I simply wanted to permanently concatenate some mp3s together. I ended up using ffmpeg to concatenate the files:

  1. First, install ffmpeg

    • Ubuntu 15.04+

      sudo apt install ffmpeg
      
    • Ubuntu 14.10 and below
      Go to http://ffmpeg.org/download.html, download one of the static builds, untar it, and copy to /usr/local/bin

  2. ffmpeg -i "concat:file1.mp3|file2.mp3" -acodec copy output.mp3

More info: https://trac.ffmpeg.org/wiki/Concatenate#protocol
https://superuser.com/a/314245


As previously suggested, mp3wrap is a good solution. It may not work all of the time though. As far as I know, mp3wrap assumes that all the input files have the same characteristics such as VBR vs CBR, bitrate, and so on. If this assumption isn't met, it is likely to fail. In that case, the only solution would be to decode all the mp3files to a raw format like .wav, concatenate them with a program like sox and finish by re-encoding all to mp3.