开发者

Combine/Concatenate MP3s on Server Using PHP

开发者 https://www.devze.com 2022-12-19 01:42 出处:网络
I have a site that will be hosting small MP3 files. I want to create a utility that will allow me to combine the mp3 files together to create a single MP3 file.

I have a site that will be hosting small MP3 files.

I want to create a utility that will allow me to combine the mp3 files together to create a single MP3 file.

I'm somewhat new to PHP but not new to programming.

Ideall开发者_如何学JAVAy, I would have a function that let me specify the a starting file and then append the second file to the existing file.

function appendMP3(originalMP3, newChunk){
   originalMP3 = originalMP3 + newChunk;
   return newMP3
}

compilation = append(compilaton, "sound.mp3");

Where do I start? Are there any existing resources?


If you can access the shell from within PHP on your environment, I would just call out to the shell (with the backtick operator) and use SoX.


Not sure how well it will work, but this blog on merging mp3 with php might help you.

Also, depending on the server it is on, you might have access to tools like sox using system() calls.


I would suggest taking a look at the PHP fopen function. If concatenating two MP3 files is as simple as stringing the bits together, then you should be able to use fopen (don't forget the "b" flag for binary) and fwrite to read in the data from one file and append it to the other.


There is an library called getID3. It has the ability to join multiple MP3 files into one , although I have never used this functionality. There is an demo available at the Source Forge site of getID3 here http://getid3.sourceforge.net/source/demo.joinmp3.phps. It seems that it works around without using any command line system calls.

I have used this library for getting lengths and other data from various media formats. It worked like a charm. However, as said, I have not tested the CombineMultipleMP3sTo() function in it...

You should test this as if it would work for you it would be a far easier option than LAME (which is powerful yet rather complicated to use in my opinion).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号