问题描述
我正在使用ffmpeg在我的网站上转换音频和视频。 Ffmpeg正确转换为其他格式,如mp3,mp4等,但不能正确转换为ogg。虽然ffmpeg正在创建ogg文件,但新创建的ogg文件已损坏,而且大小比原始文件大。我使用以下PHP代码转换为ogg。
exec(/ usr / bin / ffmpeg -i$ _FILES ['thefile1'] ['tmp_name']。./ogg/$file_name\".\".ogg);
我会假设你在看对于ogg视频,而不是音频。如果你想要音频,只需删除vcodec的东西。
添加以下参数:
code> vcodec libtheora
acodec libvorbis
所以你的命令将成为: p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ vcodec libtheora -acodec libvorbis ./ogg/$file_name\".\".ogg);
您必须确保已安装libtheora和libvorbis。如果您执行该命令并且没有安装它,ffmpeg会抛出错误。您可以使用
ffmpeg -codecs
并搜索libtheora和libvorbis。
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.
这篇关于Ffmpeg没有正确转换为ogg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!