Faster HLS preparation

Santiago Seifert
Jan 10, 2018 · 4 min read

My last medium story outlines some good practices that HLS content producers can follow to make client-side media playback easier. This post aims to describe how chunkless preparation in ExoPlayer can now take advantage of rich master playlists to shorten the initial buffering period by avoiding chunk downloads. In simple terms, chunkless preparation can help playback start faster.

Sounds good, how do I opt-in?

Available today on our dev-v2 branch, and to be available from the 2.7 release, you just need to set allowChunklessPreparation to true when creating your HlsMediaSource. Like so:

new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri, mainHandler, eventLogger)

That's it. HlsMediaSource will try to prepare without downloading any media chunks.

Will it work with any HLS master playlist?

Almost. The only essential piece of information is the CODECS attribute. It must be present in every EXT-X-STREAM-INF tag for chunkless preparation to work. If not present, traditional preparation will take place instead (look below for details).

How much faster will preparation be?

It really depends on the stream and the network conditions. Streams that benefit the most are those with multiple alternative renditions, like multiple audio languages. A simple benchmark on a nominal bandwidth of 6 Mbps yielded the following results using the demo app with the first few HLS sample streams. The preparation duration seems to be consistently shorter, but also the results show less deviation from the average.

HLS 4x3 basic stream

Chunkless average preparation duration: 1.12 seconds. Sample standard deviation: 0.77 seconds.

Traditional average preparation duration: 1.41 seconds. Sample standard deviation: 1.34 seconds.

HLS 16x9 basic stream

Chunkless average preparation duration: 1.38 seconds. Sample standard deviation: 1.14 seconds.

Traditional average preparation duration: 2.08 seconds. Sample standard deviation: 1.82 seconds.

HLS Master playlist advanced (TS)

Chunkless average preparation duration: 4.56 seconds. Sample standard deviation: 1.87 seconds.

Traditional average preparation duration: 5.75 seconds. Sample standard deviation: 3.05 seconds.

HLS Master playlist advanced (fMP4)

Chunkless average preparation duration: 2.34 seconds. Sample standard deviation: 0.72 seconds.

Traditional average preparation duration: 3.01 seconds. Sample standard deviation: 0.85 seconds.

The following two sections roughly describe how preparation works. It’s definitely worth reading before enabling chunkless preparation in a production environment, as it will help you to understand the differences compared to traditional preparation, and their implications.

Traditional preparation

Some master playlists, particularly older ones, might include incomplete or incorrect track information. To work around this, ExoPlayer also extracts information from the media content itself. This generally requires downloading a single chunk from one of the variants and one from each non-muxed audio track. This approach has two positive points:

However, for newer high quality playlists we expect all this information to be declared correctly, in which case it’s not ideal because it adds preparation overhead, and wastes some bandwidth.

Chunkless preparation

Chunkless preparation uses whatever information is available in the master playlist to build the list of tracks. The steps are:

  1. If the CODECS attribute is not present, proceed with traditional preparation.
  2. Add a track group for every EXT-X-MEDIA tag.
  3. EXT-X-STREAM-INF tags may produce both audio and video track groups. If CODECS contains a video entry, add video track group. If in addition to the video entry there is an audio entry, then add a multiplexed audio track group if and only if there are no EXT-X-MEDIA tags or there is an EXT-X-MEDIA tag with no URI attribute.
  4. If CODECS does not contain a video entry but does contain an audio entry, then add an audio track group.
  5. If CODECS does not contain an identifiable audio or video entry, preparation fails.

Other relevant points are:

Please give chunkless preparation a try and see if it works for your apps. Let us know if you can think of ways to improve it!


The ExoPlayer developer blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store