A brief introduction to the live broadcast protocol

With the development of Internet video, various online live broadcast products emerge in an endless stream, such as live show live broadcast, game live broadcast, education live broadcast, concert live broadcast, monitoring live broadcast and other live broadcast ecosystems. Behind the formation of these ecosystems is the continuous development of video live broadcast-related technologies, such as the increasing Internet bandwidth, the gradual improvement of video compression standards, and the emergence of video cloud technology.

There are many technologies involved in live broadcast, the main categories are: acquisition, preprocessing, audio and video codec, streaming media protocol, system architecture, CDN, playback control, interactive technology, etc.

Since it is a brief introduction, I will not introduce all of them, but pick a point that everyone usually talks about more.

 

streaming protocol

Streaming media protocols commonly used in live broadcasts include rtmp, http, hls, and rtsp.

Here is a brief description of the pros and cons of these protocols:

 

Protocol name

Advantage

disadvantage

rtmp

● High real-time performance: generally within 3 seconds.

● Support encryption: rtmpe and rtmps are encryption protocols.

● High stability: The most stable way to play flash on PC platform is rtmp. If you do CDN or medium and large cluster distribution, it is necessary to choose a protocol with high stability.

● General mainstream encoders support this protocol.

● The protocol is complicated: developers are tiring to write, and the efficiency is not good.

● Cache is troublesome: It is inconvenient to perform caching in streaming protocols.

http

● High performance: http has good performance, simple protocol, and perfect high-performance server. If the distribution volume is particularly large, such as an on-demand video website, and there is no real-time requirement for live broadcast, the http protocol is the best choice.

● No fragmentation: http has no fragmentation compared to hls.

● Through the wall: The http protocol is the only protocol that will definitely be opened on the Internet, so there is no end-blocking problem.

● Poor real-time performance: start with a delay of 10s.

● Poor native support: Flash on PC is ok for http streaming, but the mobile terminal does not support http very well

hls

● Good performance: same as http.

● Through the wall: same as http.

● Good native support: perfect support on iOS, poor support on Android. There are also various as plugins now supporting HLS on PC/flash.

● Poor real-time performance: It is related to the length of ts slices, and the time delay is about 3 slices. Basically, the delay of HLS is more than 10 seconds.

● File fragmentation: If HLS is distributed, the bitrate is low, and when the slice size is small, it will cause too many file fragments

rtsp

● Low latency, generally 500ms.

●  带宽好,时效率高。

●  倍速播放,主要是回放的时候提供的功能。

●  控制精准,任意选择播放点。

●  服务端实现复杂。

●  代理服务器弱:数量少,优化少。

●  无路由器防火墙穿透

●  管流分离:需要1-3个通道。

 

 

看了以上这些协议,想必各位都注意到了一个问题,那就是“延迟”。所有的协议里都有延迟,延迟最低的也有500ms。那么为什么会出现这样的情况呢?接下来,简单和大家说一说“延迟”。

 

简说延迟

 

在这里简单说一下rtmp和rtsp的延迟,我们先谈rtmp的延迟。圈内有人整理了一张直播延迟(rtmp的)的图片,我直接上个真相。

看完上图你大概就能明白了,rtmp的延迟是和gop挂钩的。

那么,为什么rtsp延迟会比rtmp低呢?因为,它是精确控制的,可以跳出这个以gop组为单位的控制。

 

rtsp延迟已经是上述四个协议里最低的了,那么延迟还有降低的空间吗?

 

如何降低延迟时间

 

我们公司经过多次测试,发现udp直接发裸流,可以将延迟控制在80ms到170ms的范围内。

 

既然udp直接发裸流延迟那么低,为啥不流行?

 

原因很简单, udp是个不可靠传输、丢包、乱序。而且直接裸流稳定性也差,兼容性更不用谈,没有编码器跟你对接。这就是一个钢丝上骑自行车的活,高难度动作,能干这行的,必须得是艺高人胆大。

 

直播涉及到的技术非常多,本文主要简单介绍了直播中用得比较多的几种协议。而对于流媒体的传输,现在出现了越来越多的私有协议,这些私有协议一般延迟都比较低,比如大家平时用的微信视频,就不属于流媒体。延迟的话,相信大家也都用过,比rtsp的500ms显然低很多。但通常来说,这些私有协议都只支持端,不能用于web开发,因为一般协议,都是用c/c++写的socket通信。

 

总结

 

就直播发展而言,最近几年的直播发展势头,用“迅猛”形容绝不为过。自14年习近平主席提出“网络强国”战略和李克强总理提出了“互联网+”的新思路新理念后,各大小直播平台如雨后春笋般涌现,甚至2016年被授予了一个特殊称号----“网络直播元年”。2017年2月19日,央视新闻移动网正式上线,为广大记者打造了移动直播系统——“正直播”。这些都标志着大数据时代、新媒体时代已经到来,媒体行业将面临新一轮的挑战和转型,这将是传媒史上一次对新闻直播技术的革新,也将成为新闻直播样态的一次革命性创举。

 

附流媒体技术图

(直播技术图,来源:CSDN)

 

 

联系我们,扫码关注微信公众号

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324371013&siteId=291194637