user547794
user547794

Reputation: 14511

PHP - convert .wav file to .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!

Upvotes: 7

Views: 13485

Answers (3)

b.b3rn4rd
b.b3rn4rd

Reputation: 8830

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

Upvotes: 1

8vius
8vius

Reputation: 5836

I do this, I downloaded and installed ffmpeg with libmp3lame.

In your code do this:

$commandOutput = shell_exec('ffmpeg (or path to your ffmpeg file) -i file.wav file.mp3')

Upvotes: 0

Jon
Jon

Reputation: 437336

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.

Upvotes: 7

Related Questions