0

What's the easiest way to merge the contents of several MP3 files into one using PHP 5.2 on Linux Debian system? I found some scripts that are supposed to do in PHP only, but they seem to be buggy. Perhaps there is a way to accomplish this task using command line programs, that I could install on my Linux Debian machine?

pako
  • 1,908
  • 4
  • 24
  • 40

2 Answers2

2

check this: http://lists.mplayerhq.hu/pipermail/ffmpeg-user/2009-September/022171.html

first you have to install sox. sudo apt-get install sox.

$ sox first.mp3 -r 44100 -c 2 -s -w first.raw
$ sox second.mp3 -r 44100 -c 2 -s -w second.raw
$ cat first.raw second.raw > concatenated.raw
$ sox -r 44100 -c 2 -s -w concatenated.raw concatenated.mp3

you can execute all these commands from php with exec().

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
0

Code taken from this link

cat first_part.mp3 second_part.mp3 third_part.mp3 > newfile.mp3

They say that your file must have the same bit rate.

You can have bit rate using mpg321

mpg321 -t first_part.mp3

Hope it helps.

Luc M
  • 16,630
  • 26
  • 74
  • 89
  • 2
    What about ID3 tags? MP3 files have headers and simply concatenating them would mess up the internal structure of the resulting file. – pako Apr 05 '10 at 20:40
  • I only have one mp3 file to test it. I did cat my.mp3 my.mp3 my.mp3 > new.mp3 and the file is playable. – Luc M Apr 05 '10 at 21:40
  • Is there a way that one can change the bit rate on the fly? If I have a large group of mp3s already, with varying bit rates. What is the best thing to do? – Scott Dec 13 '10 at 00:58