Merge mp3 files

mp3

Neither cat nor mp3wrap are working for me. They merge the files, but the when playing the resulting file, the audio length information is wrong. That is, it show the length of the 1st part (the part which was the 1st file), then the length of the 2nd … . And so on.

Other alternative that might work? In the past I was happy with ffmpeg but it was deprecated.

Best Answer

ffmpeg -i "concat:1.mp3|2.mp3|3.mp3" -acodec copy output.mp3

If you use Python, you can use a subprocess

import subprocess

subprocess.call(['ffmpeg', '-i', 'concat:1.mp3|2.mp3|3.mp3', '-acodec', 'copy', 'output.mp3'])

You can also have the paths to your mp3 in a file.

# audio-to-process.txt
file '/path/to/mp3-1'
file '/path/to/mp3-2'
file '/path/to/mp3-3'

Then,

ffmpeg -f concat -safe 0 -i audio-to-process.txt -c copy output

The -safe 0 flag is not needed if the file paths are relative.

ffmpeg concatenate api API page

Related Question