Merge two mp3 php

poiuytrez picture poiuytrez · Oct 21, 2010 · Viewed 12.8k times · Source

Do you know a class to merge two MP3 files using PHP?

I've found nothing on Google.

Answer

Gordon picture Gordon · Oct 22, 2010

If by merging, you mean placing one audio over the other, then please disregard this answer.

If you dont want to re-encode the MP3s, you can probably just append them. I know this worked for MPEG movies, so I guess it could work for MP3s too. Another option would be to add the audo files to a Zip Archive with no compression and then rename the extension to .mp3.

I did a quick test and this

file_put_contents('combined.mp3',
    file_get_contents('file1.mp3') .
    file_get_contents('file2.mp3'));

worked fine. The ID3 tags will be wrong, but the resulting file contains both audio files. For some other possible gotchas, see the link in Pekka's answer.

Also, some quick googling resulted in

and some discussion