Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Searching Google on how to join/merge many mp3 files, it suggests that I should just cat them together.

That might "work", but clearly it is not the correct way to do it, as each header and set of IDv3 tags will also be concatenated.

Does a Linux program exist that can be scripted to join/merge many mp3?

Can mplayer/mencoder/ffmpeg do it?

share|improve this question

migrated from serverfault.com Jul 23 '11 at 21:27

This question came from our site for professional system and network administrators.

3 Answers 3

up vote 29 down vote accepted

This will concatenate two mp3 files, and the resulting metadata will be that of the first file:

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

This is because, for ffmpeg, the whole "concat:" part is a single "input file", and its metadata will be of the first concatenated file. If you want to use metadata from the second file instead, you have to add it as a dummy input file and map its metadata to that of the output:

ffmpeg -i "concat:file1.mp3|file2.mp3" -i file2.mp3 -acodec copy test.mp3 -map_metadata 0:1

If you want to construct your metadata from the two metadatas, you'll have to do it by hand. You can dump a file's metadata with

ffmpeg -i file1.mp3 -f ffmetadata file1.metadata

After dumping both metadatas and constructing new metadata, you can add it to the output file with -metadata, and you can disable metadata copying by setting a -map_metadata mapping from a negative input file number. This sets a name value and no other metadata:

ffmpeg -i "concat:file1.mp3|file2.mp3" -acodec copy -metadata "title=Some Song" test.mp3 -map_metadata 0:-1
share|improve this answer
    
FYI this requires a certain version of ffmpeg. If it says file not found concat... try upgrading and running it again –  Sameer Alibhai Sep 9 '12 at 23:14
    
Works fine in ffmpeg 0.10.4 in Gentoo. What are you using? Are you sure you haven't just mistyped the command? –  Ambroz Bizjak Sep 10 '12 at 0:05
    
Ambroz I was saying that I had an old version and had to upgrade, then it worked. –  Sameer Alibhai Sep 14 '12 at 20:58
    
Typing this in a DOS box in XP doesn't work: "'file2.mp3\' is not recognized as an internal or external command, operable program or batch file". Is the command Linux-specific? –  OverTheRainbow Oct 18 '12 at 16:54
    
@OverTheRainbow the argument is supposed to be "concat:file1.mp3|file2.mp3", without the backslash. The backslash is an escape character to prevent the unix shell from treating | as a pipe. I've changed it to use double quotes instead. –  Ambroz Bizjak Oct 19 '12 at 21:19

Mp3Wrap - Command-line utility that wraps multiple MP3 files into a single, playable MP3, without losing filenames or ID3 information, and without reencoding. Also supports archiving non-audio data such as playlists, info files, and cover images inside the MP3. These files can be unpacked later (using mp3splt, e.g.); ordinary MP3 decoders can play the entire audio stream as one long track.

share|improve this answer
    
Thanks for this recommendation.. much lighter/simpler solution then ffmpeg, since I was combining 100+ mp3's and wanted the option of splitting back to originals. –  joshbaptiste May 17 at 2:29

If you need scripting, you're probably better off using the ffmpeg solution. However, if you ever just need an application to do stuff like that, you could try out Audacity. It's open source and cross platform. I haven't used it to join mp3s, but I've used it to crop sections out of an mp3 and fade them out at the end. I'm be willing to bet you can join mp3s and cross-fade them into each other with it as well.

share|improve this answer
3  
Audacity, as far as I know, works on the raw sound data, and concatenating mp3's with it will result in a degradation due to transcoding. –  Ambroz Bizjak Jul 23 '11 at 22:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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