Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - convert .wav file to .mp3?

Tags:

php

audio

mp3

I was wondering if anyone had any advice for encoding a user uploaded .wav file to a .mp3 extension. I would like to build a PHP solution if possible. Can I call the command line LAME encoder via PHP once a file has been uploaded? Is there a better option?

Thanks!

like image 204
user547794 Avatar asked Sep 15 '11 20:09

user547794


2 Answers

Go ahead and call LAME. No chance of a better option existing, even more so if you take the encoder quality into account.

The easiest way to call into an external binary is exec, while for the best integration over the encoding process you might want to use proc_open.

like image 188
Jon Avatar answered Nov 07 '22 04:11

Jon


I wrote a wrapper for LAME that provides convenient interface to encode wav file(s). The library is available here: https://github.com/b-b3rn4rd/phplame

like image 25
b.b3rn4rd Avatar answered Nov 07 '22 06:11

b.b3rn4rd