-->
Save your seat for Streaming Media NYC this May. Register Now!

How to Encode Video for HLS Delivery

Article Featured Image

In contrast, most authorities recommend making sure that the keyframe interval divides evenly into the segment size. For example, cloud encoder Zencoder’s well-written Best Practices for Encoding HLS Video states, “keyframe rate should be an even interval of the segment size.” As you see in Figure 4, all of the HLS templates implemented in Sorenson Squeeze ensure that the keyframe interval divides evenly into the segment duration, called a fragment in the application UI. As discussed above, that’s what I recommend as well, though I’ve asked Apple to explain this inconsistency, and await word back.

Encode and Segment

Beyond Apple’s tools, there are a number of programs that can encode your files and create the segments and metadata files in one operation, which is the simplest workflow. One of the least expensive is Apple Compressor 4.0 ($49.99), which only runs on the Mac. Sorenson Squeeze is cross platform and starts at $549, and offers one of the most elegant interfaces for producing HLS output, with all variants shown within a single interface (Figure 4) that ensures a common keyframe interval and consistent audio parameters.

Figure 4. Sorenson Squeeze has a very elegant interface for HLS output.

Telestream Episode, which starts at $594, can also output segments and index files, but only via command line arguments, not through the user interface. Most enterprise and cloud encoders can output HLS compatible segments and index files via the user interface or application programming interface (API).

Testing Your Files

MediaStream Validator is a command line tool included with Apple’s HTTP Live Streaming Tools. In essence, during testing, it simulates HLS playback, so you have to upload your files to a web server (or install a web server on your computer) to run the tool.

Figure 5. Running Apple’s Media Stream Validator.

Operation is simple and the command line argument is shown in Figure 5. Run time will depend upon the length of your video and the number of segments. For reference, it took for the program 65 seconds to analyze the nine streams shown in Figure 5 for a 90-second test file.

The tool can reveal a range of problems in your files, including the bandwidth issue discussed above. It will also send an error message if your segments don’t have IDR keyframes. Apple explains all error messages produced by Media Streaming Validator in Technical Note TN2235. Lack of compliance with all HLS requirements may cause playback to fail, so testing your files before making them available is recommended. If you’re submitting an application with media files to the App store for approval, you should definitely test first with Media Stream Validator. For more on this, check Apple’s Technical Q&A QA1767 entitled Resolving App Store Approval issues for HTTP Live Streaming.

This article first appeared in the 2014 Streaming Media Industry Sourcebook.

Streaming Covers
Free
for qualified subscribers
Subscribe Now Current Issue Past Issues
Related Articles

How to Encode and Deliver to Multiple ABR Formats

Use a single adaptive group, packaged differently for different targets, to keep encoding and storage costs down.

Life After Flash: Will Producers Move to HLS, DASH, or Both?

While it's clear that Flash's time is coming to an end, it's less clear what will replace it. A survey shows DASH support, but its real-world use is around one percent.