Monday, 8 July 2019

linux - How to join/merge many mp3 files?


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?



Answer



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

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...