CDN Encyclopedia Lecture 4 | How to "stall" gracefully on the cloud-the technology you have to pay attention to for live streaming

Posted Jun 15, 20205 min read

Recently, national policies have begun to encourage the land stall economy , and various enterprise platforms have launched land stall support policies for a time. The concept stocks of land stalls have soared. The ecology and supporting commodities of land stalls have also become popular, and various new The quick guide for stall owners", trillions of pyrotechnics economy has already come to the fore.

In fact, some people have already "laid a stand" on the Internet, that is to bring goods live! Affected by the epidemic, offline entities have shut down, and live broadcasts have been unprecedentedly sought after. Companies have chosen to use live broadcasts to enhance their brand image, maintain interaction with users, and complete product sales.

So the question is, what technologies do you need to pay attention to in the process of building a live broadcast platform or application? What role does CDN play in live broadcasting?

What is included in a live broadcast system?

Generally, the entire live broadcast system may include:the push stream end is accelerated by an edge node to push the live video stream to the live broadcast center, where a series of transcoding, screenshots, recording, watermarking, etc. are completed in the live broadcast center, and then the video stream passes through the CDN Distribute and distribute to different players. There are different SDKs on the player to perform optimization actions such as second opening and weak network.

Pushing and playing in the live broadcast system

For live video, the two most important links are push streaming and broadcast. Push streaming generally uses the RTMP protocol. Commonly used push streams include OBS, mobile APP, FFmpeg, etc. In addition to the RTMP protocol, HTTP FLV and HLS protocols can also be used for playback. RTMP and HTTP FLV are streaming, HLS is an accelerated file transmission. Common players include:Flash/VLC/HTML5/Mobile App, etc. For the Alibaba Cloud live broadcast system, most live broadcast distribution is done through streaming, and only a small amount is completed using files to speed up the distribution.

CDN Wiki 4-2.png

Streaming distribution and CDN live broadcast system

In fact, in the live broadcast scenario, whether it is streaming or broadcasting, streaming distribution is always connected, a live broadcast may be 5 hours, and the push flow will not be interrupted within these 5 hours. As far as the player is concerned, what the server obtains is audio and video data frame by frame. No matter what the transmission protocol is, the FLV tag is used for encapsulation. Each frame of audio or video will have a timestamp attribute.

The live video stream will transmit audio frames and video frames. For audio frames, each frame can be decoded independently. After the player obtains any frame of audio frames from the server, it can be rendered independently and the sound can be heard. The video is divided into video key frames and non-key frames. The key frames can be decoded and rendered independently. The player can directly see the picture after getting it, generally more than 10K or even tens of K; other non-key frame decoding depends on some previous video frames , The player will decode the previous frame and this frame to generate a picture, the general size of non-key frames is a few K or less than 1K. For the player, the server generally starts to send the key frames of the video, so that there will be no flower screen.

For the content stored by the live broadcast server on the node, if the file is accelerated, the content stored on the node is very clear, that is, the file data. If the URL is unchanged, the content of the file data will also be unchanged. But for live broadcast, the frame data is transmitted, and the buffered frame sequence data is also constantly changing.
As you can see in the figure below, the current server caches five frames of V1-V3 data. When the key frame of V4 appears, the server discards the previous and begins to cache the audio and video data starting from V4. This strategy ensures the playback over The end is the current latest data. Generally, the live broadcast server uses this strategy to cache the server.

CDN Wiki 4-3.png

Challenges for live streaming platforms?

  1. As mentioned earlier, the live broadcast system includes various environments such as streaming, transcoding, distribution, and playback. It has experienced a long and complicated network environment, especially when the business scenarios are gradually enriched, and the functional requirements are also increasing.
  2. The improvement of some key indicators, such as:stuttering rate, opening speed, fluency, and return-to-origin rate, etc. Any decrease in the indicators may lead to a decrease in the user experience of the entire application, affecting the live broadcast effect
  3. Live broadcast platforms often face business bursts, with hundreds of thousands or even millions of users online at the same time, which poses a huge challenge to servers and bandwidth

Why should I use CDN for live streaming platforms?

1. Reduce the lag rate and improve user experience

Live broadcast, especially e-commerce live broadcast, is very sensitive to network jitter. If there is a problem, it will cause problems such as stalls and flower screens, which will seriously affect the user experience and even directly drop the line to affect sales. CDN can use the load balancing system to push content to the edge nodes close to the user, so that the user can obtain resources nearby, which can greatly improve access efficiency.

2. When the peak of business comes, escort for the peak of traffic

In order to ensure the smoothness of live broadcasting, CDN nodes and precise scheduling systems with global coverage are indispensable. CDN nodes adopt a distributed architecture, and node resources and bandwidth reserves represent the magnitude and breadth of users that can be covered. When the burst peak is particularly high, the CDN system will ensure that more accurate scheduling strategies, such as DNS and IP scheduling, are used to reduce the impact on live broadcasting. For example, there is a cup with a lot of ice cubes and water. If we want to use all the small space in the cup, we must put the ice cubes in first and then pour the liquid water. In the context of intelligent scheduling, the combination of "solid" and "liquid" can be considered to achieve precise control of all nodes and water levels and achieve more precise scheduling.

Therefore, the selection of nodes and bandwidth resources covers a wide range, strong comprehensive strength, guaranteed quality, and CDN service providers with best practices for large-scale projects are critical to the live delivery platform. Alibaba Cloud CDN wants to turn on the "land-economy economy" on the cloud. Alibaba Cloud CDN understands:Full-speed restructuring in the middle of the year, CDN/total station acceleration, live video, video on demand and other products have launched limited-time discounts. Log in to Alibaba Cloud Official website for event details

Click to review the first lecture of CDN Encyclopedia. Has your app crashed recently?
https://segmentfault.com/a/1190000022604068
Click to review the second lecture of CDN Encyclopedia. If the CDN is not used, what will the online world look like?
https://segmentfault.com/a/1190000022611308
CDN Encyclopedia Lecture 3:If I use a cloud server, do I need to do CDN acceleration?
https://segmentfault.com/a/1190000022845869

[CDN Encyclopedia]In the column, we will continue to popularize CDN knowledge, interpret CDN practice, and share CDN cases. If you are also concerned about CDN and use CDN, please leave a reply to the topic you care about~~