What is the hls protocol?

HLS commonly used streaming media protocols mainly include HTTP progressive download and real-time streaming media protocol based on RTSP/RTP. These two basic things are completely different. At present, it is convenient and easy to use HTTP progressive download method. In this case, Apple's HTTP Live Streaming is representative of this aspect. It was originally developed by Apple for mobile devices such as the iPhone, iPod, iTouch and iPad. Now I see a lot of applications on the desktop, HTML5 is directly supporting this.

However, the small slicing method of the HLS protocol generates a large number of files, and storing or processing these files causes a lot of waste of resources. If you want to achieve a time shift of several days, the index amount will be a huge number, and obviously affect the request speed. Therefore, the HLS protocol is quite demanding on storage I/O. In this regard, some companies have proposed very good solutions.

The new on-demand server system, the original real-time slicing technology of memory cache data, subverts this traditional implementation method, fundamentally solves the problem of fragmentation of a large number of slices, making the slicing and packaging capability of a single server no longer a bottleneck. The basic principles are as follows:

The TS slice file is not stored on the disk, but is stored in the memory. This technology makes the server disk no longer have "tens of tons" of file fragments, which greatly reduces the disk I/O times and extends the server. The service life of the disk greatly improves the stability of the server operation. At the same time, due to the use of this technology, the terminal directly obtains data from the server when requesting data, which greatly improves the response speed of the terminal data request and optimizes the video viewing experience.

HTTP Live Streaming (abbreviated as HLS) is an HTTP-based streaming media network transport protocol proposed by Apple. It is part of Apple's QuickTIme X and iPhone software systems. It works by dividing the entire stream into small, HTTP-based files for download, each time only downloading some. When the media stream is playing, the client can choose to download the same resource at different rates from many different alternate sources, allowing the streaming session to adapt to different data rates. When starting a streaming session, the client downloads an extended M3U (m3u8) playlist file containing metadata for finding available media streams.

HLS only requests basic HTTP messages. Unlike Real-Time Transport Protocol (RTP), HLS can pass through any firewall or proxy server that allows HTTP data to pass. It is also easy to use a content distribution network to transport media streams.

Apple has submitted the HLS protocol as an Internet draft (phased submission) and has been submitted to the IETF as an informal standard in the first phase. However, even if Apple occasionally submits some minor updates, the IETF has no further actions regarding the development of this standard.

Introduction to HLS Protocol

The HLS Agreement provides:

The package format of the video is TS.

The encoding format of the video is H264, and the audio encoding format is MP3, AAC or AC-3.

In addition to the TS video file itself, an m3u8 file (text file) for controlling playback is also defined.

Why Apple wants to propose the HLS agreement, in fact, his main purpose is to solve some problems in the RTMP protocol. For example, the RTMP protocol does not use the standard HTTP interface to transmit data, so it may be blocked by the firewall in some special network environments. However, because HLS transmits data due to the HTTP protocol used, it will not be blocked by the firewall (it will not be blocked by the firewall even with the 80 interface).

Also under load, RTMP is a stateful protocol that makes it difficult to scale smoothly the video server because it needs to maintain state for each client that plays the video stream. While HLS is based on stateless protocol (HTTP), the client simply downloads the normal TS files stored on the server in order, and it is as simple as balancing the load as a normal HTTP file server.

In addition, the HLS protocol itself achieves rate adaptation, and devices with different bandwidths can automatically switch to the video playback that best suits their own bit rate. In fact, the biggest advantage of HLS is that his relative is Apple. Apple only provides native support for HLS on its own iOS device and gives up flash. Android is also forced to support HLS by Pingguo’s “Kuanwei”. In this way, flv, rtmp these Adobe video solutions need extra effort to play on mobile devices. Of course, the huge performance pressure caused by flash on mobile devices is also a problem of its own.

However, HLS also has some pits that cannot be crossed. For example, the video delay time of live broadcast using HLS protocol cannot be less than 10 seconds, and the delay of RTMP protocol can be as low as 3 or 4 seconds. Therefore, please be cautious with HLS for services that are sensitive to live broadcast delays.

What is the hls protocol?

Image from Apple's official website

To explain this picture, from left to right, the format of the video source of the input at the bottom left does not matter, the communication protocol between him and the server can also be arbitrary (such as RTMP), in short, just transfer the video data to the server. Just go up. This video is converted to HLS format video (both TS and m3u8 files) files on the server server. Fine splitting to see the Media encoder in the server is a transcoding module responsible for transcoding the video data in the video source to the video data of the target encoding format (H264). The encoding format of the video source can be any video encoding format ( Refer to "Video Technology Foundation"). After transcoding into H264 video data, the video is sliced ​​in the stream segmenter module, and the result of the slicing is the index file (m3u8) and the ts file. The DistribuTIon in the figure is actually just a normal HTTP file server, and then the client only needs to access the path of the first-level index file to automatically play the HLS video stream.

HLS index file

The so-called index file is the m3u8 text file that was said before.

What is the hls protocol?

Image from Apple's official website

As shown in the figure above, the logic for the client to play the HLS video stream is actually very simple. First download the first level Index file, which records the address of the secondary index file (Alternate-A, Alternate-B, Alternate-C), and then the client. The terminal then downloads the secondary index file, and the secondary index file records the download address of the TS file, so that the client can download the TS video file in sequence and play it continuously.

First level index file

Video source: https://dco4urblvsasc.cloudfront.net/811/81095_ywfZjAuP/game/index.m3u8

#EXTM3U

#EXT-X-STREAM-INF: PROGRAM-ID=1, BANDWIDTH=1064000

1000kbps.m3u8

#EXT-X-STREAM-INF: PROGRAM-ID=1, BANDWIDTH=564000

500kbps.m3u8

#EXT-X-STREAM-INF: PROGRAM-ID=1, BANDWIDTH=282000

250kbps.m3u8

#EXT-X-STREAM-INF: PROGRAM-ID=1, BANDWIDTH=2128000

2000kbps.m3u8

Bandwidth specifies the bitrate of the video stream. PROGRAM-ID is useless and does not need to be concerned. The next line of each #EXT-X-STREAM-INF is the path of the secondary index file. You can use relative path or absolute path. The relative path is used in the example. This file records the secondary index file path for different bitrate video streams. The client can determine its own current network bandwidth to determine which video stream to play. It is also possible to smoothly switch to a video stream that matches the bandwidth when the network bandwidth changes.

#EXTM3U

#EXT-X-PLAYLIST-TYPE: VOD

#EXT-X-TARGETDURATION: 10

#EXTINF:10,

2000kbps-00001.ts

#EXTINF:10,

2000kbps-00002.ts

#EXTINF:10,

2000kbps-00003.ts

#EXTINF:10,

2000kbps-00004.ts

#EXTINF:10,

. . . . . . .

#EXTINF:10,

2000kbps-00096.ts

#EXTINF:10,

2000kbps-00097.ts

#EXTINF:10,

2000kbps-00098.ts

#EXTINF:10,

2000kbps-00099.ts

#EXTINF:10,

2000kbps-00100.ts

#ZEN-TOTAL-DURATION:999.66667

#ZEN-AVERAGE-BANDWIDTH: 2190954

#ZEN-MAXIMUM-BANDWIDTH: 3536205

#EXT-X-ENDLIST

The secondary file is actually responsible for giving the download address of the ts file, and the relative path is also used here. #EXTINF indicates the duration of each ts slice video file. #EXT-X-TARGETDURATION specifies the maximum duration of the slice files in the current video stream, that is, the duration of these ts slices cannot be greater than the value of #EXT-X-TARGETDURATION. #EXT-X-PLAYLIST-TYPE: VOD means that the current video stream is not a live stream, but an on-demand stream. In other words, all the ts files of the video have been generated, #EXT-X- ENDLIST This indicates the end of the video. This flag also indicates that the current stream is a non-live stream.

Play mode

The feature of on-demand VOD is that all index files and ts files can be obtained at the current time point, and the addresses of all ts files are recorded in the secondary index file. This mode allows the client to access the entire content. The above example is the structure of m3u8 in an on-demand mode.

Live mode is to generate M3u8 and ts files in real time. Its index file has been dynamically changing. When playing, you need to continuously download the secondary index file to get the latest generated ts file to play the video. If there is no #EXT-X-ENDLIST flag at the end of a secondary index file, it is a Live video stream.

When the client plays the video in VOD mode, it only needs to download the primary index file and the secondary index file to get the download address of all ts files. Unless the client performs bit rate switching, there is no need to download any index file. You need to download the ts file in sequence and play it. But the Live mode is slightly different, because the new ts file is also being generated at the same time of playback, so the client actually downloads the secondary index file, then downloads the ts file, and then downloads the secondary index file (this time this time The secondary index file has been rewritten, the download address of the newly generated ts file is recorded, and the new ts file is downloaded, and the playback is repeated.

The request flow for HLS is:

1 http Request the url of m3u8.

2 The server returns a playlist of m3u8. This playlist is updated in real time, and the url of 5 pieces of data is generally given once.

3 The client parses the playlist of m3u8, and then requests the url of each segment in order to obtain the ts data stream.

Simple process:

What is the hls protocol?

Copper Cooling Tube

Copper Cooling Tube

[HIGH REFRIGERATION EFFICIENCY]Good heat dissipation and refrigeration capability,high strength at low temperature.Copper tubes are hollow,so has strong heat transfer capability.If you need refrigeration for refrigerators, freezers, air conditioners, this is a good choice

[COPPER MATERIAL]Copper refrigerator tube has the features of high temperature resistance, corrosion resistance, oxidation resistance, durability, long service life
[SOFT & SHAPE CHANGEABLE]Because refrigeration copper pipe can bend and deform, they can often be made into elbows and joints. Smooth bending allows copper tubes to bend at any angle
[WIDELY APPLICATION]Refrigerator Tubing is not only used for refrigerator, freezer and air conditioner as refrigeration tubing coil, but also used as a HVAC system pipe.

Condenser Copper Tube,Copper Cooling Tube,Copper Tube Air Cooling,Copper Cooling Fin Tube

FOSHAN SHUNDE JUNSHENG ELECTRICAL APPLIANCES CO.,LTD. , https://www.junshengcondenser.com

Posted on