Html 用于将 HTML5 视频转换为 mp4 和 ogg 的 ffmpeg 设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3119797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ffmpeg settings for converting to mp4 and ogg for HTML5 video
提问by betamax
Despite all the hype, in reality the HTML5 video tag has a bit of a problem. In order to use it and for it to be cross browser compatible, you have to include more than one format of the video. To target all supported browsers these formats are mp4 and ogg.
尽管大肆宣传,但实际上 HTML5 视频标签存在一些问题。为了使用它并使其跨浏览器兼容,您必须包含不止一种格式的视频。为了针对所有支持的浏览器,这些格式是 mp4 和 ogg。
I was searching around for optimum settings for each format but unfortunately I couldn't find any. I'm using ffmpeg 0.6 which has the tagline "Works with HTML5". I'm no video expert so I was wondering if anyone could recommend decent settings for each format?
我四处寻找每种格式的最佳设置,但不幸的是我找不到任何设置。我使用的是 ffmpeg 0.6,它的标语是“Works with HTML5”。我不是视频专家,所以我想知道是否有人可以为每种格式推荐合适的设置?
采纳答案by betamax
I ended up using ffmpegand ffmpeg2theora.
我最终使用了ffmpeg和ffmpeg2theora。
WebKit compatible h.264 video
WebKit 兼容的 h.264 视频
I decided to go for the ipod640 preset because it means the video can be viewed nicely on an iPhone or iPod touch. Of course, you can change the settings around a bit, get rid of the '-vpre ipod640', change the resolution or quality. Anyway the command is:
我决定使用 ipod640 预设,因为这意味着可以在 iPhone 或 iPod touch 上很好地观看视频。当然,你可以稍微改变一下设置,去掉'-vpre ipod640',改变分辨率或质量。无论如何,命令是:
ffmpeg -i video_source_file.ext -vcodec libx264 -vpre ipod640 -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 video_out_file.mp4
ffmpeg -i video_source_file.ext -vcodec libx264 -vpre ipod640 -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 video_out_file.mp4
move some information to the front of the file so the video can play before it loads
将一些信息移到文件的前面,以便视频可以在加载之前播放
qt-faststart video_out_file.mp4 video_out_file_quickstart.mp4
qt-faststart video_out_file.mp4 video_out_file_quickstart.mp4
Firefox compatible Ogg video
Firefox 兼容的 Ogg 视频
This depends on you having ffmpeg2theora installed. Also, I have only tested it with the input file being the output file from the previous ffmpeg conversion. The command is:
这取决于您是否安装了 ffmpeg2theora。另外,我只使用输入文件作为先前 ffmpeg 转换的输出文件对其进行了测试。命令是:
ffmpeg2theora -o video_out_file.ogv video_out_file.mp4
ffmpeg2theora -o video_out_file.ogv video_out_file.mp4