Live streaming player Big Three PK: RTMP / HLS / HTTP-FLV

1、RTMP:

Real-time messaging protocol, Real Time Messaging Protocol, is Adobe Systems' audio, video, and data transfer between Flash Player and the development of open server protocol. Based on the TCP protocol, a protocol suite, including protocols and RTMP substantially RTMPT / RTMPS / RTMPE other variants.

RTMP is a network protocol designed for real-time data communication, mainly used between streaming Flash / AIR platform and support RTMP protocol / server interaction for audio, video and data communications. This real-time approach is relatively strong, basically guaranteed late in 1-2s, is one of the ways the country now live mainly used; however, the use of this protocol, you must install flash, and H5, IOS, Android and not the native support for flash, so this agreement will pop how long, do not know, after all, is the current mainstream mobile terminal.

FLV (Flash Video) is Adobe launched another video format, streaming media data storage container format for transmission over the network. The format is relatively simple and lightweight, no large media header information. By the entire FLV The FLV Header, The FLV Body Tag, and other components. So load fast. FLV format file using the package suffix .flv.

2、HLS:

HLS protocol is Apple launched a live, streaming video is sliced ​​into pieces of the file to live. The client will first request a m3u8 file, which will have a different rate of flow, or directly to the file list ts, ts through the file to the address given in turn to play. In the broadcast time, the client will continue to request m3u8 file, check the list of new ts ts slices. The real poor in this way, but the advantage is H5, IOS, Android have native support.

HLS is a solution that consists of three parts: Sever, CDN, Client.

(1) Server

The video server data stream is encoded, encapsulated, and a continuous cut, short duration MPEG-TS format file, usually a slice ts about 10s; and a matching list of media files (files M3U8).

  • Encapsulation format video: MPEG-TS.
  • 编码:视频编码为H.264,音频编码为AAC, MP3, AC-3或者EC-3格式。

(2) Distribution

由标准的网络服务器组成,接收客户端的请求和分发所有的资源包括m3u8列表文件和ts分片文件。

(3) Client

客户端先通过下载m3u8文件,再通过m3u8文件的索引地址顺序地拉取ts媒体文件播放。对于直播,它的索引文件一直处于动态变化的,你需要不断的更新索引文件 playlist 然后移除旧的索引文件。

一般为了加快速度,m3u8 放在 web 服务器上,ts 文件放在 cdn 上。

HLS协议可以实现码率自适应。不同带宽的设备可以自动切换到最适合自己码率的视频播放。

另外于负载,RTMP是一种有状态协议,很难对视频服务器进行平滑扩展,因为需要为每一个播放视频流的客户端维护状态。而HLS基于无状态协议(HTTP),客户端只是按照顺序使用下载存储在服务器的普通TS文件,做负责均衡如同普通的HTTP文件服务器的负载均衡一样简单。

HLS 的优势:

  • Apple 的全系列产品支持:由于 HLS 是苹果提出的,所以在 Apple 的全系列产品包括 iPhone、 iPad、safari 都不需要安装任何插件就可以原生支持播放 HLS, 现在 Android 也加入了对 HLS 的支持;
  • 穿透防火墙。基于 HTTP/80 传输,有效避免防火墙拦截;
  • 性能高。通过 HTTP 传输, 支持网络分发,CDN 支持良好,且自带多码率自适应,Apple 在提出 HLS 时,就已经考虑了码流自适应的问题。

HLS 的劣势:

  • 实时性差,延迟高。HLS 的延迟基本在 10s+ 以上;
  • 文件碎片。特性的双刃剑,ts 切片较小,会造成海量小文件,对存储和缓存都有一定的挑战。

3、HTTP-FLV:

      HTTP-FLV就是对RTMP协议的封装,相比于RTMP,它是一个开放的协议。因此他具备了RTMP的实时性和RTMP不具备的开发性,而且随着flv.js出现,使得浏览器在不依赖flash的情况下,播放flv视频,从而兼容了移动端,所以现在很多直播平台,尤其是手机直播平台,都会选择它。

发布了4 篇原创文章 · 获赞 0 · 访问量 156

Guess you like

Origin blog.csdn.net/daniulivesdk/article/details/104227638