Convert * (mp3, m4p, and the likes) to OGG via Command Line for HTML5 compatibility

喜你入骨 提交于 2019-12-08 01:34:16

问题


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)

Convert mp3 to ogg via php


回答1:


You didn't look very far...

exec("/usr/bin/ffmpeg -i infile.mp3 -acodec libvorbis outfile.ogg");




回答2:


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.



来源:https://stackoverflow.com/questions/11930636/convert-mp3-m4p-and-the-likes-to-ogg-via-command-line-for-html5-compatibil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!