Html 用 HTML5 玩 HLS

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

Play HLS with HTML5

htmlvideostreaminghttp-live-streaming

提问by Dallox

So i'm trying to play HLS streams on HTML5 without using Flash. We've tried many video players but they all relay on a flash player. My question, is it possible to play HLS streams (any) on HTML5 without using Flash?

所以我试图在不使用 Flash 的情况下在 HTML5 上播放 HLS 流。我们尝试了很多视频播放器,但它们都在 Flash 播放器上运行。我的问题是,是否可以在不使用 Flash 的情况下在 HTML5 上播放 HLS 流(任何)?

(I know of the https://github.com/RReverser/mpegtsbut it doesn't work on mobile and is pretty laggy.)

(我知道https://github.com/RReverser/mpegts,但它在移动设备上不起作用并且非常滞后。)

回答by Sixthpoint

HLS is not supported by all browsers. I use a jwPlayer which supports both flash and HTML5 streaming (when available). Support for HLS streaming unfortunately still needs to rely on Flash to work properly across various browsers. See HTML5 HLS browser support: http://www.jwplayer.com/html5/hls/

并非所有浏览器都支持 HLS。我使用支持 Flash 和 HTML5 流媒体(如果可用)的 jwPlayer。不幸的是,对 HLS 流的支持仍然需要依靠 Flash 才能在各种浏览器中正常工作。请参阅 HTML5 HLS 浏览器支持:http: //www.jwplayer.com/html5/hls/

回答by jolumg

HLS.js project is quite reliable nowadays (https://github.com/video-dev/hls.js/tree/master). It is suppported in the latest versions of the browsers. It does not rely on Flash. It can be used in flowplayer. hls.js is compatible with browsers supporting MSE with 'video/MP4' inputs. supported on:

HLS.js 项目现在非常可靠(https://github.com/video-dev/hls.js/tree/master)。最新版本的浏览器都支持它。它不依赖于 Flash。它可以在flowplayer中使用。hls.js 与支持带有“视频/MP4”输入的 MSE 的浏览器兼容。支持:

  • Chrome for Android 34+
  • Chrome for Desktop 34+
  • Firefox for Android 41+
  • Firefox for Desktop 42+
  • IE11+ for Windows 8.1+
  • Edge for Windows 10+
  • Opera for Desktop
  • Vivaldi for Desktop
  • Safari for Mac 8+ (beta)
  • 安卓版 Chrome 34+
  • 桌面版 Chrome 34+
  • 火狐安卓版 41+
  • 桌面版 Firefox 42+
  • 适用于 Windows 8.1+ 的 IE11+
  • 适用于 Windows 10+ 的 Edge
  • Opera 桌面版
  • 桌面版 Vivaldi
  • Safari for Mac 8+(测试版)

回答by Svetlin Mladenov

There is no mature stable open-source HLS HTML5 player AFAIK. However there are two commercial offerings:

没有成熟稳定的开源 HLS HTML5 播放器 AFAIK。但是,有两种商业产品:

  • Viblast Player- very cheap and relatively easy to use. This one is just a bare minimum HLS HTML5 playback. The developer has to do the UI themselves or integrate it with Video.js/Flowplayer/JWPlayer.
  • Theo Player- I haven't had much experience with this one. The pricing is not public. The demo looks OK and it even works on most version of Firefox.
  • Viblast Player- 非常便宜且相对易于使用。这只是一个最低限度的 HLS HTML5 播放。开发人员必须自己做 UI 或将其与 Video.js/Flowplayer/JWPlayer 集成。
  • Theo Player- 我对这个没有太多经验。价格不公开。该演示看起来不错,它甚至适用于大多数版本的 Firefox。

Both of these players rely on the MSE APIand don't work on browsers where it's not supported (IE <= 10, Firefox).

这两个播放器都依赖于MSE API,并且不能在不支持它的浏览器上工作(IE <= 10,Firefox)。

回答by Daniel

Basically all HTML5 players need to transmux the MPEG2-TS (transport stream) segments to MP4 as most browsers do not support MPEG2-TS natively.

基本上所有 HTML5 播放器都需要将 MPEG2-TS(传输流)段转换为 MP4,因为大多数浏览器本身不支持 MPEG2-TS。

There are actually a few HTML5 players available which are capable of playing back HLS streams. One example would be the Bitmovin Player, which offers professional support as well as a fallback for legacy browsers. It's a commercial product, but they also provides a free plan. Also open-source projects like hls.jsare available.

实际上有一些 HTML5 播放器可以播放 HLS 流。一个例子是Bitmovin Player,它提供专业支持以及旧浏览器的后备。这是一个商业产品,但他们也提供免费计划。也可以使用像hls.js这样的开源项目。

However, with Apple's announcementfrom this year's WWDC it's now also possible to use MP4 segments with HLS, which eliminates the need to transmux. More details on how to do it and advantages are outlined pretty well in this article. Not sure which players support it, at least Apple's native implementation in Safari on iOS 10 and macOS; also Bitmovin already supports it.

然而,随着Apple 在今年的 WWDC上宣布,现在也可以将 MP4 片段与 HLS 一起使用,从而消除了转多路复用的需要。如何做到这一点,优势更多细节概述不错这篇文章。不确定哪些玩家支持它,至少苹果在 iOS 10 和 macOS 上的 Safari 中原生实现;Bitmovin 也已经支持它。

回答by MrP

THEOplayeris very interesting for this case. They allow to stream using HLS to all the popular browsers and platforms without using Flash.

对于这种情况,THEOplayer非常有趣。它们允许使用 HLS 流式传输到所有流行的浏览器和平台,而无需使用 Flash。

They have support for Internet Explorer, Firefox, Chrome, Opera and Safari on Windows, Linux, Mac, iOS, Android and Windows Phone.

它们支持 Windows、Linux、Mac、iOS、Android 和 Windows Phone 上的 Internet Explorer、Firefox、Chrome、Opera 和 Safari。

Also, contrary to earlier answers, they don't rely on MSE in order to function. As a result, this player works on all the platforms and even old IE versions (10 and up) and browsers that do not support MSE.

此外,与之前的答案相反,他们不依赖 MSE 来运行。因此,该播放器可在所有平台上运行,甚至可以在不支持 MSE 的旧 IE 版本(10 及更高版本)和浏览器上运行。