What Is HLS Streaming And When Should You Use It?

There have been major changes in the digital broadcasting world in recent years. Flash, an Internet content delivery technology developed by Adobe is rapidly dwindling and its place has been taken by protocols like HLS.

HTML5 and HLS are built on open source, so you can change them to your liking and use them for free. They are also safer, more reliable and faster than their predecessors. In this article, we will try to reveal the concepts of HLS streaming and when you should use it.

What is HLS?

HLS stands for HTTP Live Streaming, a protocol for streaming multimedia data over the Internet. HLS cuts the MP4 video content into short blocks of 10 seconds. These short snippets are delivered over HTTP, making the protocol compatible with most devices and firewalls.

First of all, HLS provides excellent quality online broadcasts. However, it should be borne in mind that the delay in online broadcasting is 15-30 seconds. On the server-side, the creator of the broadcast can assign the encoding of the stream in different qualities. The player then dynamically requests the optimum quality based on the Internet channel's bandwidth at a given time. As a result, the quality of the fragments can vary.

For example, a cell phone plays the video in HD quality, and one minute later, the viewer enters the poor reception area. When the player detects a decrease in connection quality, it requests lower quality video blocks. This reduces buffering, freezing and other problems.

What is Streaming?

Streaming is a way of delivering audiovisual media to users over the Internet. It works by sending the media file to the user's device a little at a time and continuously, rather than in a single block. The original media file is stored remotely or, in the case of live streaming, is created in real-time with a camera or microphone. This way, the video or audio can be played without the user's device having to download the entire file first.

HLS HTTP Videostreaming Cinema8videos

What is HTTP?

HTTP is an application layer protocol that serves to transfer information between devices connected to a network. All websites and applications that give regular users access run over HTTP. Data transfers over HTTP are usually based on requests and responses. Most HTTP messages are a request or response to a request.

In streaming over HTTP, the classic request-response sequence does not apply. The connection between client and server remains open for the duration of the stream, and the server sends video data to the client so that the client does not have to request every segment of the video data.

How Does HLS Work?

Server: An HLS stream originates on a server where the media file is stored (in on-demand streaming) or where the stream itself is created (in the live stream). Since HLS is HTTP-based, any regular web server can originate the stream.

Two main processes take place on the server:

Encoding: The video data is reformatted so that each device can recognize and interpret it. HLS must use H.264 or H.265 encoding.

Segmentation: the video is divided into segments, each of a few seconds in duration. The length of the segments can vary, even if the default length is 10 seconds.

In addition to splitting the stream into segments, HLS creates a video segment index file to record their order. To sum up, HLS also creates several segment duplicates at different quality levels: 480p, 720p, 1080p and so on.

Distribution: Encoded video segments are sent to client devices over the Internet when they request the stream. Typically, a content delivery network (CDN) helps distribute the stream to different geographic areas. The CDN also caches the stream to send it to clients even faster.

Client device: The client device is the one that receives the stream and plays the video, such as a user's smartphone or laptop. The client device uses the index file as a reference to assemble the video in the right order, and switches from higher to lower quality (and vice versa) as needed.

What is Adaptive Bitrate Streaming in HLS?

One of the advantages of HLS over other streaming protocols is adaptive bitrate or ABR streaming. This refers to the ability to adjust video quality in the middle of a stream to accommodate changes in network conditions. This capability allows videos to continue playing even when network conditions deteriorate; conversely, it maximizes video quality to the highest level supported by the network.

If the network slows down, the user's video player detects it and ABR streaming lowers the stream's quality so as not to interrupt the video playback. As the availability of more bandwidth increases, ABR streaming improves the quality of the data stream.

ABR streaming is possible because, during the segmentation process, HLS creates several duplicate segmented streams with different quality levels. The user's video player can then seamlessly switch between streams while playing the video.

History Of The Creation Of HLS

HLS was originally launched by Apple in the summer of 2009, along with the iPhone 3. Previous iPhone models encountered problems with online transmission because they sometimes switched between Wi-Fi networks and mobile data transmission.

HLSStreamVideo Cinema8videos

Prior to the release of HLS, Apple's primary media streaming protocol was Quicktime Streaming Server. This offered good service, but because it used non-standard ports for data transmission, its RTSP protocol was periodically blocked by firewalls. Together with the slow internet, this has led to the abandonment of this protocol. But the lessons learned from its implementation have been very helpful in developing HLS.

The Technical Side

The HLS stream is created on the fly and stored on the HTTP server. Video files, as mentioned above, are split into short fragments with the extension .ts - MPEG2 Transport Stream.

The HTTP server also creates a playlist file with the extension .M3U8 (also called manifest), which is used to index all video blocks. This playlist file points to additional index files for each of the existing broadcast qualities. Even if you choose to broadcast using only one quality, the "manifest" will still be created.

The user player must acknowledge the deterioration or improvement of the data transmission speed on the Internet. When such an event occurs, the player consults the manifest file to determine which video quality to switch to. The player then requests an index file for a specific quality to download the snippet of video where the viewer stopped. The whole process is invisible to the user. The HLS protocol also supports closed captioning,

When to Use HLS For Online Streaming

It is recommended that you always use HLS because it is the most modern and widely supported media streaming protocol. You can't do without it if you want to cast on mobile devices. Furthermore, HLS is the most up-to-date and widely used protocol for streaming media and can be used in the following scenarios:

1. When Streaming to Mobile Devices

If you want to cast to mobile devices and tablets, HLS is mandatory. Since mobile devices now account for the majority of Internet traffic (about 75% of traffic in 2019), HLS is essential.

2. When Streaming With An HTML5 Video Player

Native HTML5 videos are not compatible with RTMP or HDS. So, if you want to use a purely HTML5 video player, HLS is the only option. In addition to reaching mobile devices, these considerations point to HLS as the standard. If you are currently stuck with Flash technology , RTMP will be a better delivery method - but only if you have no other option.

3. When Faster Playback is Required

Playback time is quite crucial for every streaming video player, and HLS technology effectively provides faster playback with the help of Amazon's web services with no downtime.

The HLS player provides end-end support to users with flawless and robust quality among other live streaming formats. To summarize, HLS streaming technology has several advantages like adaptive streaming method, supports different platforms, contains multi-bit speed, which can be deployed on desktop and various mobile devices without any problems.