From Spotify to Netflix, streaming services are now a part of everyday life for many consumers. In the U.S. alone, 62% of adults currently subscribe to at least one streaming service. Whether audio or video content is being streamed on your smartphone or on demand on your TV, the likelihood is high that the HTTP Live Streaming (HLS) protocol is involved. In this blog post, we’ll discuss HLS streaming, answer the question “what is HLS?” and highlight how the HLS protocol works and best practices for implementing HLS video streaming solutions.
What Is HLS?
Developed by Apple, HTTP Live Streaming (also known as HLS) is an HTTP-based adaptive bitrate streaming communications protocol that delivers audio and video media over the web, from media servers to viewers’ devices.
HTTP, or Hypertext Transfer (or Transport) Protocol, is the data transfer protocol that runs the world wide web. Because it’s completely ubiquitous in the network, there’s a lot of infrastructure for servers and clients, and the HLS protocol takes advantage of that and uses the existing infrastructure to distribute streaming content. Benefits include content delivery scaling, security and routing.
When you generate HLS video or HLS audio content, you can produce the content with varying quantity or quality. The quality is directly proportional to the bitrate. With HLS streaming, the highest quality has the highest bitrate, and the lowest quality has the lowest bitrate. Let’s say you’re watching a high-definition movie at 1920×1080 (1080p). As your device plays the content back, it plays along fine. But when your kids jump on the network, your available bandwidth decreases. When the client network can’t keep up, you experience some glitches as the protocol adapts to a lower bitrate.
Support for HLS streaming is widespread in media players, web browsers, mobile devices and streaming media servers. Plus, since the HLS protocol is an industry standard, all Mac, Android, Microsoft and Linux devices can play streams delivered using HLS, making it the most popular over-the-web playback mechanism.
How Does HLS Work?
Streaming works in two parts: The first is acquiring and packaging the content to stream; the second is serving it to clients via HLS. Content acquisition in a typical live streaming situation starts with content acquisition from a camera and microphone. The raw content is sent to a video encoder to compress it, and the output of the encoder is typically transmitted to an origin server using a protocol like RTMP. The origin server prepares the content for HLS streaming and provides an HLS URL that video players can use to get the video and render for the end user.
When content producers and broadcasters create content for HLS streaming, they make two sets of files:
- Text files — These text-based playlist or manifest files are easy to produce. They are written to a web server, and then the client reads that. The file contains tags or instructions in the playlist that will describe what content is available, what the bitrates are and whether it’s live or playback (video on demand (VOD)). Then, it describes the various media files needed to fetch the actual media and play back the stream.
- Media files — These media files are associated with the text files and are fetched from the same web server. As such, servers deliver enough audio or video content (in five- to 10-second pieces) to play for a while before going and getting more when it starts to run out.
This separation of text and media is what makes HLS so efficient and popular. The text files are small and easily modified to customize the stream for the end user (say for targeted ads), and the media can be hosted and shared with high efficiency to a large number of users using content delivery networks.
Further, media delivered using the HLS format are not “streams” per se, they’re instead progressive downloads that send segments of content data from regular web servers to devices, delivering the highest media quality and best playback experience possible for users — regardless of the connection, software or device being used.
To deliver the highest media quality, the HLS protocol segments video content into smaller chunks. Next, the server stores those streams, and players monitor changing bandwidth conditions, checking the original text-based manifest file for the location of additional streams before looking to the stream-specific media file for the URL of the next chunk of media data, seamlessly switching between chunks. HTTP Live Streaming delivers MP4 video chunks to viewers’ devices and will then play video encoded with the H.264 or HEVC/H.265 codecs. The HTTP server will create a UTF-8 Encoded Audio Playlist file that indexes video chunks. While HLS streaming appears technically complex, the streaming process is seamless and imperceptible by end users.
The Advantages and Disadvantages of HLS Streaming
In terms of media streaming quality, the HLS specification offers some major advantages:
- HLS is easy to deploy and designed for reliability.
- HLS is flexible. It allows you to play back audio, video and closed captioning of various bitrates.
- HLS is versatile. Content creators often have the option to encode the same livestream at multiple quality settings. Viewers can dynamically request the best option available, given their specific bandwidth at any given moment. The adaptive bitrate means if the network is congested or if viewers/listeners have a poor network connection, they can go to a lower bitrate and get a smaller resolution video or lower bitrate audio.
- HLS is highly scalable. Due to the web technology that underlies HLS, it can easily scale for delivery using ordinary web servers across a global content delivery network (CDN).
- HLS is cost-efficient. As noted, HLS streaming is supported by just about every device — there’s no need to use a specific device to watch or listen to the content. Plus, standard web servers can handle HLS delivery without issues. And because HLS works through standard web servers, there isn’t a lot of (new) infrastructure involved to distribute it. Additionally, you can use your old authentication and encryption techniques.
- HLS can work as a playback mechanism. Any video, movie, song or podcast can be put into a web server and served up. Or live media content can be produced and added as time goes on. Clients will keep refreshing the new media to play it back.
- Through tags, HLS allows content creators and broadcasters to insert ads, closed captions and subtitles, fast forward and reverse playback, and alternate audio and video renditions in a simple, standardized fashion.
In terms of disadvantages, the only disadvantage HLS streaming used to have — which is being fixed now — is latency. Historically, HLS favored stream reliability over latency. Consequently, when content creators or broadcasters would go live with HLS, there would be a significant gap between live, or what’s happening right now, and the time the client would actually see the playback. But speed is the name of the game in livestreaming.
Fortunately, Apple heard the industry’s calls for lower latency audio and delivered an extension of the HLS protocol: Low-Latency HLS. Low-Latency HLS enables low-latency content streaming, promising to achieve sub-two-second latencies at scale while offering backward compatibility to existing clients. In May, the Low-Latency HLS specification was incorporated into the overarching HLS protocol.
For additional information on how to enable Low-Latency HLS, check out Apple’s overview detailing how to add Low-Latency HLS to your content streams to maintain scalability.
How To Deploy an HLS Stream — A Tutorial
In order to deploy HLS, users require just three things:
- Either an HTML page or a client app. A webpage can be complex and support trick modes and timelines or as simple as a single HTML video tag. Client applications require more work but will provide more flexibility and support and a more customized user experience.
- A web server or CDN. Hardware devices that support HLS streaming will supply their own web server, and any client can stream media directly from them. Other systems must copy media and manifest files to a web server. This can be done in various ways — through AWS or Azure, on a file system or via complex network protocols. Systems that anticipate heavy traffic will need to use or develop a content delivery network (CDN). Many CDNs allow for virtually infinite traffic and are very easy to scale.
- A method for encoding source material or livestreams as fragmented MPEG-4 media files containing high-efficiency video coding (HEVC) or H.264 video and advanced audio coding (AAC) or AC-3 audio. Hardware devices that support HLS will not need to be transcoded and can be directly streamed. Almost any media can be transcoded to a format supported by HLS standards. There are many tools available to do this. Many of the best ones are free, but there are commercial products that can import media and then export HLS to just about any destination. This is the stage where a system defines the bitrates (file sizes) that it will support.
With those three requirements in place, deploying HTTP live streaming is as simple as the following steps:
- Create an HTML page or client application.
- Configure your web server as normal (or using a CDN).
- Validate your streams using a media stream validator that both simulates an HLS session and verifies that the index file and media chunks conform to the specification.
- Encrypt key media files.
- Publish your content.
HLS vs. Other Streaming Protocols
While many options exist, HLS is — generally speaking — currently the best option for streaming media protocols.
Adobe HTTP Dynamic Flash Streaming (HDS)
Specifically designed for compatibility with Adobe’s Flash video browser plug-in, the HDS protocol is smaller than HLS but enables lower latency for devices and browsers supporting Flash video.
Microsoft Smooth Streaming (MSS)
Microsoft’s live streaming protocol, MSS — like HLS — uses adaptive bitrate to enable the best streaming quality available. While MSS was one of the first available adaptive bitrate streaming methods, HLS is almost always preferred.
Dynamic Adaptive Streaming over HTTP (MPEG-DASH)
The newest protocol on this list, MPEG-DASH offers a few key advantages: adaptive bitrate, international standardization leading to extensive global adoption and the ability to utilize a variety of encoding formats. While this protocol is new and not widely used, many experts expect it to soon become the industry standard for streaming media.
Real-Time Messaging Protocol (RTMP)
Known as Flash by most people, this protocol was initially designed in the mid-2000s for audio and video streaming — serving as the internet’s default video streaming method for almost a decade. As HLS grows in popularity, however, RTMP usage is declining. While most streaming video hosting services still receive streams in RTMP stream format to ingest live streams via HLS, even this application is declining.
Real-Time Streaming Protocol (RTSP)
Helping manage and control livestream content rather than actually transmitting it, RTSP is a ’90s-era protocol known for its incredibly low latency. However, RTSP is limited: The protocol is not as compatible, adaptable nor scalable as other choices.
Given its numerous advantages over these alternative options, HLS is the industry standard for livestreaming video content due to its broad player support, scalability and cost-effectiveness.
Contact Cardinal Peak for HLS Streaming Support
HLS streaming has a lot of industry support. Many security cameras and other media hardware directly provide HLS as a source and clients to play their media over a network. Industry frameworks such as Amazon Kinesis Video Streams, VLC, FFmpeg, GStreamer, Wowza Streaming Engine and Dolby.io Real-Time Streaming support it. Therefore, all of the players and encoders based on those frameworks support it as well. Most tools that users need to create basic HLS production and consumption are already made or can easily be scripted to produce it.
An excellent solution for media distribution, HLS streaming is simple, scalable and secure. HLS video streaming ensures the best possible viewing experience from any device, anytime, anywhere. If you’re interested in delivering content everywhere, give us a call! Our expert HLS streaming engineers leverage decades of cable and video industry experience to empower you and your customers with the best possible streaming experience.