Join multiple MP3 files (lossless)
Solution 1:
Use ffmpeg or a similar tool to convert all of your MP3s into a consistent format, e.g.
ffmpeg -i originalA.mp3 -f mp3 -ab 128kb -ar 44100 -ac 2 intermediateA.mp3
ffmpeg -i originalB.mp3 -f mp3 -ab 128kb -ar 44100 -ac 2 intermediateB.mp3
Then, at runtime, concat your files together:
cat intermediateA.mp3 intermediateB.mp3 > output.mp3
Finally, run them through the tool MP3Val to fix any stream errors without forcing a full re-encode:
mp3val output.mp3 -f -nb
(source)
Solution 2:
You can do this programmatically with ffmpeg's concat demuxer.
First, create a file called inputs.txt with lines like
file '/path/to/input1.mp3'
file '/path/to/input2.mp3'
file '/path/to/input3.mp3'
...etc. Then, run the following ffmpeg command:
ffmpeg -f concat -i inputs.txt -c copy output.mp3
It's possible to generate inputs.txt easily with a bash for loop (this can probably be done with a Windows batch for loop too), assuming you want to merge the files in alphabetical order. This will match every *.mp3 in the working directory, but it can be easily modified:
for f in ./*.mp3; do echo "file '$f'" >> inputs.txt; done
## Alternatively
printf "file '%s'\n" ./*.mp3 >> inputs.txt
It's also possible to do the entire thing in one line, avoiding the creation of an intermediate list file with process substitution:
ffmpeg -f concat -i <(printf "file '%s'\n" ./*.mp3) -c copy output.mp3
Solution 3:
You can use the free mp3cat:
mp3cat indir - > outfile.mp3