1. IntroductionHi, everyone. I am your Xiaomi. Today I want to talk to you about the live streaming process of community live streaming. This process seems simple, but in fact there are many complex technical supports behind it. Today we will break down the key points so that everyone can have a clearer understanding of the technology behind the live streaming! 2. The live broadcast end uses the RTMPS protocol to send live streaming data to the nearest proxy server in the POPThe first step of live broadcast is for the host to push the video and audio streams out on the live broadcast device. In order to ensure the security of data transmission, we will use the RTMPS protocol. What is RTMPS?RTMPS is the abbreviation of Real-Time Messaging Protocol Secure. It adds an SSL/TLS encryption layer to RTMP (Real-time Messaging Protocol), making data more secure during transmission. Because during the live broadcast, users' personal information, payment information, etc. involve privacy and sensitive data, using encryption protocols can prevent information from being intercepted or tampered with. Where to send it?The live stream of the RTMPS protocol will be sent to the nearest proxy server in the POP (Point of Presence). POP is a node in the Internet backbone network. The main responsibility of the proxy server is to be as close to the user and the anchor as possible to reduce the delay in data transmission, so as to ensure that the live broadcast seen by the audience is more real-time. In short: the anchor uses RTMPS to send the encrypted live stream to the proxy server closest to him. The proxy server will try to reduce the delay and improve the live broadcast experience. 3. The proxy server forwards the live streaming data to the gateway server in the data center (443 to 80)After the proxy server receives the live stream, it will forward the data to the gateway server located in the data center. There is a small detail to pay attention to here, that is, the port conversion. The Secret of Port NumbersRTMPS uses port 443 by default when transmitting data, because port 443 is the default port for SSL/TLS encrypted data. However, in order to be compatible with some scenarios, our data center gateway server will convert the data on port 443 to port 80. Port 80 is the default port for HTTP services and is usually used for unencrypted data transmission. This conversion helps our server work properly in different scenarios. For example, in some specific network environments, port 80 may be smoother. To summarize: the proxy server forwards the encrypted live streaming data from port 443 to the gateway server, and the gateway server converts the data to port 80 for subsequent processing. 4. The gateway server uses the consistent hashing algorithm of the live broadcast ID to send the live broadcast data to the specified encoding serverNext, after receiving the data, the gateway server uses a method called consistent hashing algorithm to decide which encoding server the live data should be sent to. What is consistent hashing?The consistent hashing algorithm is a commonly used load balancing algorithm in distributed systems. By mapping the live broadcast ID (i.e. the unique identifier of each live broadcast) to a hash ring, it can be ensured that the live broadcast data is always sent to the same encoding server. In this way, even if the number of servers changes, it can ensure that the data is evenly distributed and will not cause large-scale redistribution due to the increase or decrease in the number of servers. Simply put, the consistent hashing algorithm can help us find the most suitable server to handle each live broadcast, ensuring stability and performance. After the live stream reaches the encoding server, the encoding server will undertake a series of tasks. It can be said that this step is a very important part of the entire live broadcast process. Let's take a look at what the encoding server does! 4. Verify whether the live broadcast data format is correctFirst of all, the first thing the encoding server needs to do is to verify the format of the live data, such as whether the encoding format of the video and audio complies with the regulations, and whether the parameters such as the frame rate, resolution, bit rate, etc. of the live data are within a reasonable range. If the data does not meet the standards, the encoding server will immediately return an error message and notify the live broadcast end to make adjustments. This step is very important because if there is a problem with the data format, the audience may experience problems such as screen freezes and audio and video asynchrony when watching the live broadcast. 5. Associate the live broadcast ID and the first mapping of the encoding serverIn order to ensure that the host and the audience can continue to live broadcast seamlessly even in the event of network interruption or expansion, the encoding server needs to establish a mapping relationship. In other words, it will bind each live broadcast ID to a specific encoding server. Even in some cases, the streamer's device is disconnected from the server, and when it reconnects, it will still be directed to the same encoding server. This is why you will find that when the stream is disconnected and reconnected, the picture is smooth and the audience can hardly even feel the interruption. 6. Use live data to encode output data of different resolutionsThe next step is one of the core tasks of the encoding server: transcoding. Live broadcast data often needs to adapt to different viewing environments of viewers, such as some using high-speed networks, some using low-speed networks, and some using mobile phones, tablets, or large-screen TVs. Therefore, the encoding server needs to convert the live broadcast data into different resolutions and bit rates, such as 720p, 1080p, 4K, etc. In this way, no matter what device the audience uses or what the network conditions are, the encoding server can push the most appropriate version according to demand to ensure the audience's viewing experience. 7. Use the DASH protocol to output data and store it persistentlyIn the final step, the encoding server will output the encoded data using the DASH (Dynamic Adaptive Streaming over HTTP) protocol. DASH is an adaptive streaming technology based on HTTP that dynamically adjusts the video quality based on the viewer's network conditions to ensure that the live broadcast remains smooth even when the network fluctuates. At the same time, the encoding server will store these live broadcast data persistently, so that the live broadcast playback function can be realized. After the live broadcast ends, the audience can still view the previous live broadcast content, forming more interactive opportunities and value-added content. ENDWell, the above is the live streaming process of community live streaming that we talked about today. From the live streaming end to the POP proxy server, to the port conversion and load distribution of the gateway server, and finally to the transcoding and output of the encoding server, this series of steps ensures the efficiency and stability of the live streaming. Live streaming is not just about the interaction between the anchor and the audience. Behind it, there is actually a whole set of complex technical architectures supporting it. These technologies ensure the smoothness, image quality and data security of the live streaming, which makes the experience of watching live streaming better and the effect of selling goods more significant. |
[51CTO.com original article] In 2016, Gartner cha...
[[417941]] This article is reprinted from the WeC...
The tribe has shared information about Aoyo Zhuji...
On April 25, the 4th Digital China Summit was gra...
On June 24, according to foreign media reports, S...
Domestic cloud service providers such as Alibaba ...
At present, under the long-term goal of carbon ne...
80VPS is an early established Chinese hosting com...
【51CTO.com Quick Translation】 Undoubtedly, mobile...
In today's connected world, network cables pl...
As more and more enterprises begin to realize the...
IDC——Innate Investment Gene As social division of...
Ever since Kevin Kelly predicted the bright prosp...
Nowadays, whether people like it or not, the Inte...
Arthur C. Clarke, a famous British science fictio...