当前位置:网站首页>RTMP streaming exception fast recovery scheme

RTMP streaming exception fast recovery scheme

2022-06-23 07:33:00 Video cloud live broadcast helper

1、 Problem analysis

We take an actual network case To introduce the problem ,3 month 9 Japan , Anchor in Brazil , flow id:stream-2990700835946365032

stay 20:50-21:50 During this period, the overall streaming frame rate is very low , Frame loss is very serious , But the number of users is very large , Yes 5w+ People online , Down close 100G Playback bandwidth

from cdn From the perspective of playback quality , Corresponding time period , The Caton rate is very high , The viewing quality is very poor .

In an emergency , Cut off the flow and force the flow pushing end to push the flow again , The stability of the push stream is quickly restored .

As shown in the figure above , stay 21 spot 47 about , After re streaming , The streaming frame rate is stable at 30 frame , The Caton rate also returned to normal .

After analysis , The anchor is in Brazil , The upstream connection is also in Brazil , There are a lot of slow logs on the server :

In fact, due to the single tcp Slow connection problem , It often occurs in the complex overseas streaming environment . Overseas links are complicated , And the link is very long , Sometimes at the beginning, the flow quality is very stable , After a long time , After the network jitters , There will be the deterioration of the above network , Cause unstable data transmission .

Developed countries such as Europe and the United States have good network quality , The bandwidth is sufficient , Can meet the normal live streaming . In some developing countries , Like the Middle East , Southeast Asia , The telecommunications infrastructure is poor , Insufficient network bandwidth , Local operators have various bandwidth limitations . It is easy to push streams after a period of time , The network is unstable , After the cut-off is pushed back, it can return to normal . To avoid scheduling to the same node , Usually through configuration host The way , Specify the access node , To avoid scheduling to the same node , To resume normal streaming .

The above abnormal conditions , Generally, it is pushed again by cutting off the flow or switching the flow nodes , It can often solve most problems . There is a high risk of the server actively disconnecting the anchor , If the streaming end is not handled well , There will also be an exception of the anchor streaming , This leads to streaming failure , It is easy to cause complaints , Therefore, it usually needs to be handled manually . The disadvantages of manual processing are obvious , The high cost , The problem was not dealt with in time , It takes a long time to deal with problems .

In order to solve the above problems , utilize rtmp302 characteristic , Made an improvement plan . If the server detects that the streaming is slow , adopt amf Control the way messages are sent , Push the new streaming address , Send to the streaming end , The streaming end combines the local network conditions , To make a comprehensive decision whether to cut off the flow and push again .

The highlight of this scheme is that the server only provides suggestions , Don't make decisions , The client can combine the information provided by the terminal and the background , Conduct a comprehensive assessment , Compare unilateral decisions , It can greatly improve the accuracy of decision-making .

2、RTMP 302 Redirect the specific scheme

In order to solve the problem of , Network anomaly , Adopted RTMP 302 Redirection scheme , The specific implementation logic is shown in the figure below :

Step one , In the process of streaming ,rtmp server The client supports continuous weak network detection , Support domain name + Configuration weak network detection of publishing point dimension .

Step two , When this condition is detected , It is necessary to report to the dispatching system , According to client IP, Request a legal 、 High quality streaming access node IP, Splicing complete redirection streaming addresses , adopt amf data To the streaming client .

Step three , The streaming client identifies the corresponding amf data,

The streaming terminal gets redirect After the redirection address in , Integrated local information , Determine whether it is necessary to cut off the flow and push again , if necessary , Use the address provided by the server to push the stream again , Solve the slow problem .

For details, please check the specific RFC file :

1.https://tools.ietf.org/html/rfc7016#section-3.5.1.6

2、http://www.adobe.com/cn/products/adobe-media-server-professional/features._sl_id-contentfilter_sl_featuredisplaytypes_sl_all.html

AMS Say it's built-in support :

Server redirection

Automatically provide video players with new or alternate locations if content is missing using built-in redirection in RTMP similar to HTTP 302 redirection.

The above solutions , In the process of streaming , adopt RTMP 302 To get the slow information of the server , According to the client-side and server-side slow information , To cut off the flow and push again , Quickly resume live broadcast , Improve the success rate of streaming .

Extend the above scheme , When starting streaming , utilize 302 Load balancing on the server . When the server just receives the client data , Send... To the client RTMP 302 Information , For high load 302 Dispatch , Improve the success rate of streaming . It can also be done through 302 Quickly propose abnormal streaming access points .

3、 Conclusion

in summary :

1、 In the process of streaming , Send... To the client RTMP 302 Control messages , The client uses the redirection address provided by the server , Conduct cut-off and re push , You can quickly recover streaming exceptions , Improve the quality of upstream streaming ;

2、 At the beginning of streaming , The server can integrate the background machine load and bandwidth resources , Load balancing scheduling for streaming , Provide high-quality access points for clients , Improve streaming quality , Improve the availability of platform access .

3、 Compatibility is good. , Compatible with new and old clients , Whether the inspection RTMP 302 amf Information , Completely controlled by the client . The client can , For selective use .

4、 Higher success rate of decision-making , Compared with the traditional client cut-off and re push strategy , This scheme can integrate the information of client and server , To formulate a better retry strategy for disconnection .

原网站

版权声明
本文为[Video cloud live broadcast helper]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201130058258614.html