-1

I have a form where the admin can upload an mp3. Is it possible to use ffmpeg from PHP to convert that mp3 to wav when I process the form submission?

Ryan
  • 5,883
  • 13
  • 56
  • 93

1 Answers1

1

Second google result: ffmpeg -i foo.mp3 -acodec pcm_s16le bar.wav. Wrap that with a shell_exec.

Matt
  • 5,315
  • 1
  • 30
  • 57
  • 2
    Be sure to sanitize the form input (i.e. file name) before executing that so you don't create a command injection vulnerability on your web server. – Dave Rager Feb 26 '13 at 21:57
  • I'm trying to do the exact same thing, except with a few extra parameters... I need the .wav file to be **24bit**, **96khz**, and **stereo** I read that pcm_u8 can only convert to 16bit, so is 24bit impossible? – Evan Butler Oct 27 '15 at 00:40
  • Try `ffmpeg -i foo.mp3 -acodec pcm_s24le -ar 48000 bar.wav` Keep in mind that it's not magically going to recreate additional data to fill in data that has been lost. You won't gain anything by using 24bit here. You'll essentially be creating data from mp3 artifacts at best. If you were starting with a lossless source that's another story. – Matt Oct 27 '15 at 20:46