Page 1 of 1

Combine/Concatenate MP3 Files Using PHP

Posted: Fri Jan 29, 2010 1:12 pm
by scotthoff
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.

Ideally, I would have a function that let me specify the a starting file and then append the second file to the existing file.

Code: Select all

 
function appendMP3(originalMP3, newChunk){
      originalMP3 = originalMP3 + newChunk;
}
 
Where do I start? Are there any existing resources?

Re: Combine/Concatenate MP3 Files Using PHP

Posted: Fri Jan 29, 2010 1:43 pm
by Christopher
You wouldn't do it that way. ;)

If you want to combine the files, then you would probably call some program using exec() (or similar function). However, it might make more sense to find a MP3 player that supports playlists. Then you can just generate a playlist (usually XML) to "combine" the files.

Re: Combine/Concatenate MP3 Files Using PHP

Posted: Fri Jan 29, 2010 1:45 pm
by scotthoff
Well then,

So I have the PHP execute some program on the linux box? Would GoDaddy let me do that?

Re: Combine/Concatenate MP3 Files Using PHP

Posted: Fri Jan 29, 2010 2:10 pm
by Christopher
Ask them. ;)

Some types of files can simply be concatenated. Others need the headers removed, to be spliced together, and a new header generated. If you know about MP3 internals it may be possible to read the file headers of the multiple files, generate a new header, send it to the browser, and then send the data from each file to the browser sequentially. The browser would see it as one longer MP3. There may be some PHP code that does this already out then on the interwebs somewhere.