How to join mp3 and wav files

833 views Asked by At


Hi all,
I've a PHP application to manage audio files. I've two input about audio files: file wav and file MP3

My application joins all files in to an unique mp3 file, and so I convert the wav file in mp3 file before to join them.

I'm using LAME.
File wav (conversion):

lame -m m -b 128 file.wav filewav.mp3

File mp3 (in mp3 - to create the mp3 file with same characteristics of wav conversion):

lame --mp3input -b 128 file.mp3 filemp3.mp3

The problem is: I can't join files if they are different format (filewav.mp3 and filemp3.mp3)! Is it possible to join different files?

Thank you Pasquale

1

There are 1 answers

1
FoxDeploy On

This is more of a 'How do I approach this problem' type of question.

It's not too hard, you just need to add some logic to your script to first check and see if all files are of the same format. If they are not, then determine which ones need to be converted and run separate lame conversions on each file which isn't in your desired format. Like so:

lame -V2 input.wav output.mp3

Then, at the end of your code, join them all together with the same join statement you're using there.

lame --mp3input -b 128 file.mp3 filemp3.mp3