I am using ffmpeg to convert audio and video on my website. Ffmpeg is properly converting to other formats like mp3, mp4, etc. but not converting properly to ogg. Although ffmpeg is creating the ogg file but the newly created ogg file is corrupted and too much bigger in size than the original one. I am using the following PHP code to convert to ogg.
exec("/usr/bin/ffmpeg -i ".$_FILES['thefile1']['tmp_name']." ./ogg/$file_name".".ogg");
I'm going to assume that you're looking for ogg video, not audio. If you wanted audio, just remove the vcodec stuff.
Add the following parameters:
vcodec libtheora
acodec libvorbis
So your command would become:
exec("/usr/bin/ffmpeg -i ".$_FILES['thefile1']['tmp_name']." -vcodec libtheora -acodec libvorbis ./ogg/$file_name".".ogg");
You have to make sure that you have libtheora and libvorbis installed. ffmpeg will throw an error if you execute that command and you don't have them installed. You can check using
ffmpeg -codecs
and searching for libtheora and libvorbis.
来源:https://stackoverflow.com/questions/6863445/ffmpeg-not-converting-properly-to-ogg