Joining MP3 music files to a single track

Joining MP3 files can be rather simple task with a cat command. Suppose we have a directory with multiple MP3 files. The following cat command will join all MP3 files in a current directory to a single file called out.mp3:

$ cat *.mp3 > out.mp3

If we wish to join only specific files we can name them on a command line separately:

$ cat file1.mp3 file2.mp3 > out.mp3

NOTE: You will lose all tags such as artist, album which are related to each track.

This approach is good if all of your MP3 files are from the same album which means that there is a good change that they all have same volume settings. If we wish to join MP3 files with different volume setting we first need to perform normalization first, so there will be no sudden volume spikes between tracks:

$ normalize-mp3 *.mp3

In case you do not have normalize-mp3 command available but you only have normalize or normalize-audio command you need to first convert all MP3 files to a wav format:

$ for i in $( ls *.mp3); do ffmpeg -i $i $i.wav; done

Next normalize all volume settings for each wav file:

$ normalize-audio *.wav

Now we either convert all files to MP3 and join them with cat command or we can use sox command to join all wav files to a single file and then convert it to MP3 format:

$ sox file1.wav file2.wav file3.wav out.wav

And now convert the out.wav file to mp3 with ffmpeg:

$ ffmpeg -i out.wav -acodec libmp3lame out.mp3