Merge two mp3 php

前端 未结 5 1581
青春惊慌失措
青春惊慌失措 2020-12-05 22:10

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

I\'ve found nothing on Google.

5条回答
  •  渐次进展
    2020-12-05 22:37

    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

    • http://www.sourcerally.net/Scripts/20-PHP-MP3-Class
    • http://codingforums.com/showthread.php?t=169069

    and some discussion

    • http://ask.metafilter.com/21381/Merge-mp3s-with-PHP

提交回复
热议问题