Reputation: 266
What options do I have for converting MP3's to OGG on the fly using PHP? I assume the only way to do this is via the command line with an execute statement. Is this true? If so, what converters (and associated commands) would I be best off using?
I have tried:
oggenc2.exe but was told by the program that the MP3 I passed was not a valid filetype
ffmpeg.exe but was unable to figure out how to go from mp3 to ogg (found how to go from ogg to mp3 though)
Upvotes: 2
Views: 3395
Reputation: 4054
It is now recommended (see note below) to use avconv to convert audio and video files instead of ffmpeg.
avconv -i in.mp3 -ar 16000 out.ogg
Where 16000 is the sample rate. You can inspect the sample rate of the source file with:
file in.mp3
Note: I got this warning on my Ubuntu box using ffmpeg: THIS PROGRAM IS DEPRECATED. This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Upvotes: 1
Reputation: 46602
You didn't look very far...
exec("/usr/bin/ffmpeg -i infile.mp3 -acodec libvorbis outfile.ogg");
Upvotes: 8