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)
.setAllowChunklessPreparation(true)
.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:

  • Information that is missing in the playlist is completed if available in the media. Example: closed captions language.

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.

Other relevant points are:

  • Closed caption tracks are exposed if and only if they are declared by the master playlist.

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!

google-exoplayer

The ExoPlayer developer blog

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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