How to join/merge many mp3 files?
Solution 1:
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
Solution 2:
This will concatenate a folder full of MP3 into a single MP3 file:
1) Save a list of the MP3 files to concatenate, e.g.,
$ cat mylist.txt
file '/tmp/01.mp3'
file '/tmp/02.mp3'
file '/tmp/03.mp3'
file '/tmp/04.mp3'
file '/tmp/05.mp3'
file '/tmp/06.mp3'
file '/tmp/07.mp3'
2) Run the following command (-safe 0
is not required if mylist.txt uses relative paths instead):
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp3