You’d think it would be very easy to combine multiple MP3 files into one, while preserving all the ID3 tag metadata and without re-encoding the audio (which is lossy). Well, it actually isn’t that hard at all, but since Google couldn’t find the answer for me, I thought I’d write it up.
Update 3/2011: Although it’s possible you’ll come back to the method on this page, you should check out my new-and-improved approach.
I did this on my Powerbook, so these directions should work fine on any Mac/Linux/BSD/Unix system.
There is a handy command-line utility for combining MP3 files, mp3wrap. Unfortunately, it doesn’t correct the audio duration tags/headers (so iTunes/iPod will only see the first part of the file), and it clobbers your ID3 tags with its own (so that the file can later be unmerged with mp3split — this is a “feature”). There’s also the easy cat solution (
cat 1.mp3 2.mp3 > all.mp3), but it doesn’t correct the duration, either. Maybe you don’t care about ID3 tags, and your playback software doesn’t care about a wrong duration header (some ignore it) — in that case, go away! But if you want to get your MP3 files right or you’re using something like iTunes, which does care, read on.
Install mp3wrap, ffmpeg and id3lib if you don’t have them already. On Linux, you’ll likely just use your distro’s package manager to do this in a few seconds. On my Mac, I just installed mp3wrap and id3lib from source (easy “./configure && make && make install”) and used the ffmpeg binary from ffmpegX (since Fink mangled dependencies).
Do this (combines 1.mp3, 2.mp3 and 3.mp3 into all.mp3, and copies ID3 tags from 1.mp3):
mp3wrap tmp.mp3 1.mp3 2.mp3 3.mp3 ffmpeg -i tmp_MP3WRAP.mp3 -acodec copy all.mp3 && rm tmp_MP3WRAP.mp3 id3cp 1.mp3 all.mp3
Here’s what’s happening:
- mp3wrap merges the files. Unfortunately, it also leaves wrong file duration headers and clobbers any original ID3 tags.
- ffmpeg deletes the incorrect file duration. You could also use something else, like mplayer/mencoder (
-oac copyoption) here.
- id3cp copies the ID3 tags from 1.mp3 to all.mp3