HTML 的 H.264/FLV 最佳实践
我经营一个网站,其中包含大约 700 个参考视频(不,这不是色情片——别再胡思乱想了:-))。
这些视频目前为 FLV 格式。我们使用 JWPlayer 来渲染这些视频。 IIS6 托管。一切都很好。
据我了解,H.264(不是 FLV,也可能不是 OGG)是新兴的首选 HTML5 视频标准。如今,iPad 实际上只支持 H.264 或 YouTube。据推测,很快许多更重要的浏览器将追随 Apple 的领导并只尊重 HTML5 标签。
好的,所以我想我可以弄清楚如何将现有视频转换为正确的 H.264 格式。有各种可用的工具,包括 ffmpeg.exe。我还没有尝试过,但我认为在摆弄编解码器设置后这不会成为问题。
我的问题更多的是关于容器本身——也就是说,为所有用户规划优雅的过渡。渲染这些视频的最佳实践建议是什么?如果我只使用 HTML5 标签,那么任何尚不支持 HTML5 的浏览器可能都看不到这些视频。如果我通过 JWPlayer 或其他播放器以 Flash 格式渲染它们,那么它们将无法在 iPad 上播放。我是否必须在这里进行丑陋的 UserAgent 检测才能确定要渲染的内容?
我知道 JWPlayer 支持 H.264 媒体,但播放器本身不是 Flash 组件,因此无法在 iPad 上播放吗?抱歉,如果我没有说清楚,但我正在摸索一个优雅的过渡计划,该计划将适用于当前的浏览器、iPad 和即将到来的 HTML5 浪潮。我不是视频专家,所以非常欢迎任何建议,谢谢。
I run a website that has as part of it about 700 reference videos (And no, it's not porn -- get your mind out of the gutter :-) ).
The videos are currently in FLV format. We use the JWPlayer to render those videos. IIS6 hosted. Everything works just fine.
As I understand it, H.264 (not FLV and likely not OGG) is the emerging preferred HTML5 video standard. Today, the iPad really only respects H.264 or YouTube. Presumably, soon many more important browsers will follow Apple's lead and respect only the HTML5 tag.
OK, so I think I can figure out how to convert my existing videos into the proper H.264 format. There are various tools available, including ffmpeg.exe. I haven't tried it yet, but I don't think that's going to be a problem after fiddling with the codec settings.
My question is more about the container itself -- that is, planning graceful transition for all users. What's the best-practice recommendation for rendering these videos? If I just use the HTML5 tag, then presumably any browser that doesn't yet support HTML5 won't see the videos. And if I render them in Flash format via the JWPlayer or some other player, then they won't be playable on the iPad. Do I have to do ugly UserAgent detection here to figure out what to render?
I know the JWPlayer supports H.264 media, but isn't the player itself a Flash component and therefore not playable on the iPad? Sorry if I'm not being clear, but I'm scratching my head on a graceful transition plan that will work for current browsers, the iPad and the upcoming HTML5 wave. I'm not a video expert, so any advice would be most welcome, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
请注意,Firefox 不支持使用视频标签的 H.264,因此如果您想要优雅的回退,那么您应该像下面一样渲染视频标签并拥有 OGG 版本的视频。
Be aware Firefox does not support H.264 with the Video Tag, so if you want a graceful fallback then you should render your video tag like below and have an OGG version of the video.
我不确定这是一个答案还是只是一个评论,但我确实需要挑战最初问题的假设之一:“据推测,很快许多更重要的浏览器将追随苹果的领导,只尊重 HTML5 标签。”
这是没有任何我所看到的证据支持的。
无论如何,为了解决问题的实质:“我的问题更多是关于容器本身 - 也就是说,为所有用户规划优雅的过渡。渲染这些视频的最佳实践建议是什么”
HTML5 视频标签支持命名多个源,因此如果浏览器不支持直接 H.264 视频流,您可以将本机 H.264 视频作为“主要”视频,将 Flash 播放器作为要使用的“后备”视频。
I'm not sure if this is an answer or just a comment, but I really need to challenge one of the assumptions of the original question: "Presumably, soon many more important browsers will follow Apple's lead and respect only the HTML5 tag."
This just isn't backed up by anything that I can see.
Anyway, to get to the real meat of the question: "My question is more about the container itself -- that is, planning graceful transition for all users. What's the best-practice recommendation for rendering these videos"
The HTML5 video tag supports naming multiple sources, so you can put the native H.264 video as the 'primary' and the Flash player as the 'fallback' to be used if the browser does not have support for the straight H.264 video stream.
建议您阅读适合所有人的视频,以实现良好的跨浏览器实现。您也可以使用 H.264 作为 Flash 后备,但正如 Lachlan 所说,您也应该使用 Ogg 进行渲染,以获得完全的跨浏览器兼容性。
Suggest you read video for everybody for good cross browser implementation. You can use the H.264 for Flash fallback too but as Lachlan says you should render with Ogg too for full cross browser compatibility.
每个浏览器对视频编解码器的支持如下:
我建议也提供 Ogg Theora 替代方案。我知道您是否担心磁盘空间并不重要,但由于专利使用费和对专利流氓的恐惧,这就是我们所陷入的情况。
The support in each browser for video codecs is like this:
I would recommend prividing an Ogg Theora alternative as well. I know it's not idea if you're concerned about disk space, but with all thanks to patent royalties and fear of patent trolls, it's the situation we're stuck with.
不直接回答您的问题,但 doom9.org 有大量有关视频转换/处理的精彩教程。可能对你有用
Doesn't answer your question directly, but doom9.org has loads of great tutorials on video conversion/processing. could be useful for you
由于 Chrome 从未真正停止支持 h264,因此 Firefox 也保留了它,并计划更好地支持该格式。
https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats
(大约页面下方的 1/3)
Since Chrome never actually pulled the plug out for h264 support, Firefox kept it as well and is planning better support of the format.
https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats
(about 1/3rd of the way down the page)