Html 如何处理 Chrome 中糟糕的 HTML5 视频性能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14411977/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:04:02  来源:igfitidea点击:

How to deal with poor HTML5 video performance in Chrome?

htmlvideo

提问by Jim McKeeth

Over a year ago we added an video pageon our site. At the time OGV wasn't very good, and there was no good WebM encoders available, so we decided to use HTML5 and h.264 for webkit browsers (Chrome, Safari, etc.) and then fallback to Flash for other browsers (using the same h.264 source file.)

一年多以前,我们在我们的网站上添加了一个视频页面。当时 OGV 不是很好,也没有好的 WebM 编码器可用,所以我们决定对 webkit 浏览器(Chrome、Safari 等)使用 HTML5 和 h.264,然后为其他浏览器回退到 Flash(使用相同的 h.264 源文件。)

This has been working great for a while. Recently (month or two maybe, so over multiple Chrome versions - currently Version 24.0.1312.52 m) we discovered Chrome really lagging on the playback. We thought it was a server issue, so we upgraded the server, and it is still behaving the same. I remembered reading that Google wanted to drop h.264 and move everyone to WebM, and thought this performance was part of that. We converted some videos to WebM and tested them with Chrome and they lag just as bad. Same video (WebM) streams beautifully in FireFox, and the MP4 streams great in FireFox via the Flash plug in.

这已经有一段时间了。最近(也许一两个月,所以在多个 Chrome 版本中 - 当前版本 24.0.1312.52 m)我们发现 Chrome 在播放上确实滞后。我们认为这是服务器问题,所以我们升级了服务器,它的行为仍然相同。我记得读过谷歌想要放弃 h.264 并将所有人转移到 WebM,并认为这种性能是其中的一部分。我们将一些视频转换为 WebM 并使用 Chrome 对其进行了测试,它们的延迟也同样糟糕。相同的视频 (WebM) 在 FireFox 中流畅地播放,而 MP4 通过 Flash 插件在 FireFox 中流畅地播放。

I went to YouTube and turned on the HTML5 video support, and found the videos to lag in Chrome too (when running at HD) while they play fine in Flash mode. (Even when HTML5 is enabled, some videos still play via Flash.)

我去了 YouTube 并打开了 HTML5 视频支持,发现视频在 Chrome 中也滞后(以高清模式运行时),而它们在 Flash 模式下播放良好。(即使启用了 HTML5,一些视频仍然通过 Flash 播放。)

Tested on both Windows 8 and Mountain Lion.

在 Windows 8 和 Mountain Lion 上均已测试。

I've talked to co-workers and they are seeing the same issues. So it isn't just me. So my question is:

我和同事谈过,他们也看到了同样的问题。所以不仅仅是我。所以我的问题是:

  1. Is this an issue with our video encoding?
  2. Is it a bug with Chrome?
  3. Or is it just localized to us?
  4. Is there a way to deal with this besides switching back to Flash?
  1. 这是我们视频编码的问题吗?
  2. 这是Chrome的错误吗?
  3. 或者它只是本地化给我们?
  4. 除了切换回 Flash 之外,还有其他方法可以解决这个问题吗?

回答by Jorge Antonio Díaz-Benito

HW-acc video decode

HW-acc 视频解码

This is the flag I mean. If the flag is disabled, the browser tries to use hw-accelerated video decoding, which I can grant provokes wrong and slow video renderization in some devices. If enabled, hw-accelerated video decode is never used, but the above mentioned problems disappear. It theorically increases decoding time in devices actually able to use such acceleration, but I've been working around this field for almost a year and I still didn't realize any difference in that matter. Still didn't get to know how to identify if a device will behave properly (the availability of this feature doesn't seem to grant its proper behavior) with such acceleration without testing, though.

这就是我说的旗帜。如果该标志为disabled,浏览器会尝试使用硬件加速视频解码,我可以在某些设备中授予错误和缓慢的视频渲染。如果启用,则永远不会使用硬件加速视频解码,但上述问题会消失。从理论上讲,它增加了实际上能够使用这种加速的设备的解码时间,但我已经在这个领域工作了将近一年,但我仍然没有意识到这方面的任何区别。但是,仍然不知道如何在未经测试的情况下通过这种加速来确定设备是否会正常运行(此功能的可用性似乎并未授予其正确的行为)。