The Basics of HLS Protocol: When to Use HLS Streaming Protocol
HLS live streaming solutions have become more popular lately. There are some reasons why, the most important being RTMP lost its support at the end of 2020.
Join the DZone community and get the full member experience.Join For Free
HTML5 live streaming solutions have become more popular lately. One of them is the HLS protocol. There are some reasons why this is so popular, the most important of which is that RTMP lost its support at the end of 2020.
In 2017, Adobe announced that it would no longer support RTMP after the end of 2020. After this date passed, the question of what HLS is gained more importance. Adobe’s RTMP protocol is now a thing of the past.
However, will it be beneficial for viewers and broadcasters to switch to HLS and, therefore, HTML5? We mentioned one of the most important reasons above. Additionally, HTTP-based protocols deliver the best video quality and viewer experience possible, regardless of the connection, software, or device.
Other reasons for this transition are that HTML5's streaming protocols (HLS, WebRTC, etc.), which have revolutionized the live streaming world, are safer, more reliable, and much faster than “old” technologies.
But, it is necessary to plan this change process well. Although HTML5 protocols are exciting technologies, the transition to them requires time and effort. As we mentioned, HTML5 standards deeply affected the live streaming world.
In this blog post, you will find the answer to the question of what HLS streaming is, the advantages of HLS, and why you should switch your live streaming solution to HLS.
Let’s dive into the definition of HLS!
What Is HLS Streaming Protocol (HTTP Live Streaming)?
So, what is HLS? HLS stands for HTTP Live Streaming. HLS is an adaptive HTTP-based protocol used for transporting video and audio data from media servers to the end-user’s device.
HLS was created by Apple in 2009. Apple announced HLS at about the same time as its legendary device, iPhone 3. Earlier generations of the iPhone had live streaming playback problems, and Apple wanted to fix this problem with HLS.
Features of HLS Video Streaming Protocol
- Closed captions.
- Fast forward and rewind.
- Alternate audio and video.
- Fallback alternatives.
- Timed metadata.
- Ad insertion.
- Content protection.
HLS Technical Specifications
- Audio Codecs: AAC-LC, HE-AAC+ v1 and v2, xHE-AAC, Apple Lossless, FLAC.
- Video Codecs: H.265, H.264.
- Playback Compatibility: It was created for iOS devices, but is now supported by: all Google Chrome browsers; Android, Linux, Microsoft, and macOS devices; several set-top boxes, smart TVs, and other players.
- Benefits: Supports adaptive bit rate, it's reliable, and it's widely supported.
- Drawbacks: Video quality and viewer experience are prioritized over latency.
- Latency: HLS allows us to have 5-20 seconds of latency, but the Low-Latency HLS extension has now been incorporated as a feature set of HLS, promising to deliver sub-2-second latency.
What Is Low-Latency HLS?
Here’s how Apple explained Low Latency HLS:
Low-Latency HLS extends the protocol to enable low-latency video streaming while maintaining scalability. The new low-latency mode lowers video latencies over public networks into the range of standard television broadcasts.
What Is a Protocol?
Yes, HLS is a live streaming protocol. But, it is useful to explain the term 'protocol,' which we constantly hear. So, what is a streaming protocol? A streaming protocol is a standardized method of transmitting video or audio content between devices over the internet.
A video streaming protocol sends “chunks” of video or audio content from one device to another. The method of converting these “chunks” into playable content on the device is called the “reassembling” method.
For a successful process, the end device must support the protocol used by the sender.
What Is a Codec?
Codecs are compression technologies with two components: an encoder to compress the file in the first device and a decoder to decode the file when played by the end device (viewers).
HLS supports many popular codecs such as:
- Audio: AAC-LC, HE-AAC+ v1 and v2, xHE-AAC, Apple Lossless, FLAC.
- Video: H.265, H.264.
How Does HLS Work?
Now that we’ve answered the question of what HLS video streaming is, we can go one step further. Before comparing HLS with other solutions, it would be better to learn how HLS works.
Image Source: Streaming Media
HLS works like all adaptive streaming technologies. Multiple files are created for distribution to the player, which can adaptively change streams to make the viewer’s experience “perfect.” Since it is an HTTP-based technology, no streaming server is required, so all adjustments are made on the player device.
To distribute to HLS clients, the source is encoded into multiple files at different data rates and divided into short chunks (segments of data) which are usually around 10 seconds long. This process is also called segmented delivery. These are loaded onto an HTTP server along with a text-based manifest file with a .M3U8 extension that directs the player to additional manifest files for each of the encoded streams.
Segmented delivery allows the player to shift between different video qualities depending on available resources of the viewers’ conditions, while also driving down latency.
Advantages of HLS Streaming Protocol
The biggest advantage of HLS is its wide support area. HLS is currently the most used streaming protocol. However, the HLS protocol offers a latency of 5-20 seconds.
HLS’s adaptive bit rate capabilities ensure that broadcasters deliver the optimal user experience and minimize buffering events by adapting the video quality to the viewer’s device and connection.
Players can automatically adapt and adjust for changes in network speed, preventing stalls when the local connection is unstable.
Devices and Browsers That Support HLS
As we said, the HLS streaming protocol is supported by a wide range of devices and browsers.
Once limited to iOS devices such as iPhones and iPads, HLS is now supported by the following devices and browsers:
- All Google Chrome browsers.
- Microsoft Edge.
- iOS devices.
- Android devices.
- Linux devices.
- Microsoft devices.
- macOS platforms.
When to Use HLS
As we said, HLS is currently the most used streaming protocol, which is why live broadcasters have definitely heard of HLS.
HLS can be used in streams where video quality is important, but latency is not an issue.
When Not to Use HLS
If you care about delay and interaction in your broadcasts, HLS is not for you. If you are looking for a solution in a field such as video conferencing, the best and only solution for you is WebRTC.
HLS vs. RTMP
RTMP is a protocol, created by Macromedia and now owned by Adobe, that provides high-performance transmission of video, audio, and data between dedicated streaming servers and Adobe Flash Players across the internet. RTMP was created for high-performance transmission of media such as audio and video.
However, Adobe will stop updating and distributing the Flash Player. We said above that HLS is the most popular protocol. With the fall of RTMP, this popularity seems likely to increase even more.
It is time to move from RTMP to HTML5 solutions.
HLS vs. WebRTC
We answered the question of what HLS streaming is and learned its positive aspects. The worst feature of HLS is that it provides high latency. If latency is important to you, WebRTC is the right choice.
WebRTC (Web Real-Time Communication protocol) is an open-source standard for real-time communication supported by almost every modern browser, including Safari, Google Chrome, Firefox, Opera, and others. That support ensures that the WebRTC standard will remain up-to-date and functional for the foreseeable future.
Thanks to WebRTC video streaming technology, you can embed real-time video directly into your browser-based solution to create an engaging and interactive streaming experience for your audience without worrying about the delay. WebRTC provides a sub-second delay of around 0.5 seconds.
Published at DZone with permission of Hamit Demir. See the original article here.
Opinions expressed by DZone contributors are their own.