Apple HLS: technical in-depth

Last updated on May 5, 2020.

Content

An introduction to Apple HLS is available as: Apple HLS: introduction.

A summary table of the versions and revisions is available as: Apple HLS: comparing versions.

Master, Variants and Renditions

A complex presentation can be described by a Master Playlist.

The Master Playlist provides a set of Variant Streams, each of which describes a different version of the same content.

A Variant Stream can also specify a set of Renditions. Renditions are alternate versions of the content, such as audio produced in different languages or video recorded from different camera angles.

Version 1

The initial version defines nine new tags:

EXTM3U

AnExtended M3U file is distinguished from a basic M3U file by its firstline which MUST be #EXTM3U.

EXTINF

An Extended Info Marker describing the media file that follows it:

#EXTINF:<duration>,<title>

EXT-X-TARGETDURATION

Approximate duration ofthe next media file (the real duration must be less or equal). The EXTINF duration segment file must be less than or equal than EXT-X-TARGETDURATION:

#EXT-X-TARGETDURATION:<seconds>

EXT-X-MEDIA-SEQUENCE

Sequence number:

#EXT-X-MEDIA-SEQUENCE:<number>

Starting at version 5, aclient shall notassume that segments with the same media sequence number indifferent masters, variants or renditions contain matching content.

EXT-X-KEY

Optional tag. The encryption algorithm is AES-128 CBC with PKCS7 padding:

#EXT-X-KEY:METHOD=<method>[,URI="<URI>"]

EXT-X-PROGRAM-DATE-TIME

Associates the beginning of the nextmedia file with an absolute time:

#EXT-X-PROGRAM-DATE-TIME:<YYYY-MM-DDThh:mm:ssZ>

Starting at revision 20 (version 7) it should provides milliseconds:

#EXT-X-PROGRAM-DATE-TIME:<YYYY-MM-DDThh:mm:ss.SSSZ>>

EXT-X-ALLOW-CACHE

Specifies whether the client may cachedownloaded media files for later replay:

#EXT-X-ALLOW-CACHE:<YES|NO>

EXT-X-STREAM-INF

The next URI in the Playlist is another Playlist file:

#EXT-X-STREAM-INF:[BANDWIDTH=<n>],[PROGRAM-ID=<i>],[CODECS="[format][,format]*"]<URI>

EXT-X-ENDLIST

We reached the end of the playlist:

#EXT-X-ENDLIST

EXT-X-DISCONTINUITY

Added in revision 2.

Indicates that the next media filehas different characteristics than the previous one:

#EXT-X-DISCONTINUITY

Version 2

EXT-X-STREAM-INF (additions)

TheRESOLUTION=<N>x<M> attribute is added.

EXT-X-VERSION

Indicates the compatibility version of thePlaylist file:

#EXT-X-VERSION:<n>

EXT-X-KEY(additions)

Added the optional IV attribute.

Version 3

EXTINF(additions)

The duration can be expressed with a floating point argument.

EXT-X-PLAYLIST-TYPE

Optional:

#EXT-X-PLAYLIST-TYPE:<EVENT|VOD>

If the tag is present and has avalue VOD, the playlist shall not change. If the tag is present and has avalue of EVENT, the server may only append lines tothe playlist.

Version 4

Rendition groups

A set of EXT-X-MEDIA tags with the same GROUP-ID value forms a groupof renditions.

EXT-X-STREAM-INF (additions)

New AUDIO and VIDEO attributes.

AUDIO (resp. VIDEO)
The value is a quoted-string. It MUST match the value of the
 GROUP-ID attribute of an EXT-X-MEDIA tag elsewhere in the Playlist
 whose TYPE attribute is AUDIO (resp. VIDEO). It indicates the set of audio
 renditions that MAY be used when playing the presentation.

EXT-X-BYTERANGE

Indicates that a media file is a sub-range of the resource identified by its media URI:

#EXT-X-BYTERANGE:<n>[@o]

With:

  • n: length of the sub-range
  • o (optional): offset, may be inferred from the previous media segment length and computed offset.

EXT-X-MEDIA

Indicates that playlists contain alternaterenditions of thesame content. For example two audio languages, or two video camera angles:

#EXT-X-MEDIA:[TYPE={AUDIO,VIDEO}],[URI],[GROUP-ID],[LANGUAGE],[NAME],[DEFAULT={YES,NO}],[AUTOSELECT={YES,NO}]

EXT-X-I-FRAME-STREAM-INF

Identifies a playlistcontaining the I-frames of a multimedia presentation. It stands alone, in that it does not apply to a particular URI in the playlist:

#EXT-X-I-FRAME-STREAM-INF:<attribute-list>

Same attributes asEXT-X-STREAM-INF, minus the AUDIO attributes, plus a URI attribute to identify the I-frame playlist file.

EXT-X-I-FRAMES-ONLY

Indicates that each media segment in thePlaylist describes a single I-frame:

#EXT-X-I-FRAMES-ONLY

Version 5

Subtitle segments

They must use WebVTT.

Each WebVTT segment MUST have an X-TIMESTAMP-MAP metadata header.

EXT-X-KEY (additions)

New encryption method SAMPLE-AES.SAMPLE-AES only encrypts the audio and video payloads. This is how DVB encryption works also.

The legacy encryption in HLS was called AES-128. AES-128 encrypts the full TS packets including headers.

The possible attributes are URI,IV,KEYFORMAT,KEYFORMATVERSIONS.

EXT-X-MEDIA(additions)

The TYPE attribute can have the value SUBTITLES.

New attributes [FORCED={YES,NO}], [CHARACTERISTICS=UTI].

EXT-X-MAP

The EXT-X-MAP tag specifies how to obtain the Transport Stream PAT/

PMT for the applicable media segment.

It applies until the nextEXT-X-DISCONTINUITY tag

#EXT-X-MAP:<attribute-list>

With the attributes URI and BYTERANGE.

Version 6

EXT-X-MEDIA (additions)

Added the TYPE attribute value CLOSED-CAPTIONS. The media segments for the video renditions caninclude closed captions.

The attributes URI,ASSOC-LANGUAGE,CHARACTERISTICS andINSTREAM-ID={CC1,CC2,CC3,CC4} are added.

EXT-X-STREAM-INF (additions and removals)

TheCLOSED-CAPTIONS attribute is added.

The PROGRAM-ID attribute is removed.

EXT-X-I-FRAME-STREAM-INF(removals)

The PROGRAM-ID attribute is removed.

EXT-X-DISCONTINUITY-SEQUENCE

Allows synchronization betweendifferent renditions of the entire playlist, same variant stream or different variantstreams that have EXT-X-DISCONTINUITY tags in their playlists:

#EXT-X-DISCONTINUITY-SEQUENCE:<number>

For revision 13 specifically, a playlist that contains an EXT-X-PLAYLIST-TYPE tag with avalue of EVENT or VOD must notcontain an EXT-X-DISCONTINUITY-SEQUENCE tag.

EXT-X-START

Indicates a preferred point at which to startplaying a playlist:

#EXT-X-START:[TIMEOFFSET],[PRECISE={YES,NO}]

Media Segments (audio only)

Each Elementary Audio Stream segment MUST signal the timestamp of its
 first sample with an ID3 PRIV tag [ID3] at the beginning of the
 segment. The ID3 PRIV owner identifier MUST be
 "com.apple.streaming.transportStreamTimestamp". The ID3 payload MUST
 be a 33-bit MPEG-2 Program Elementary Stream timestamp expressed as a
 big-endian eight-octet number, with the upper 31 bits set to zero.

EXT-X-INDEPENDENT-SEGMENTS

Added at revision 13.

Indicates that all media samplesin a segment can be decoded without information from other segments:

#EXT-X-INDEPENDENT-SEGMENTS

Version 7

The specification was re-written in a more readable way.

Alternative Renditions

EXT-X-STREAM-INF tag containing an AUDIO, VIDEO, SUBTITLES, or CLOSED-CAPTIONS attribute indicates that alternative Renditions are available for playback of that Variant Stream.

EXT-X-SESSION-DATA

Allows arbitrary session data to becarried in a Master Playlist:

#EXT-X-SESSION-DATA:<attribute list>

The attributesDATA-ID, VALUE, LANGUAGE and URI are defined.

EXT-X-STREAM-INF (additions)

TheAVERAGE-BANDWIDTH attribute was added.

TheFRAME-RATE attribute was added in revision 15.

TheHDCP-LEVEL attribute was added in revision 20.

EXT-X-ALLOW-CACHE (removal)

The tag was removed.

EXT-X-MEDIA (additions)

INSTREAM-ID value SERVICE indicated a CEA-708DigitalTelevision Closed Captioning.

(Revision 20): the attribute CHANNELS is added.

EXT-X-DATERANGE (revision 19)

associates a time/date range (oddly named “Date Range”) with an attribute/value pair:

#EXT-X-DATERANGE:<attribute list>

The attributesID, CLASS, START-DATE, END-DATE, DURATION, PLANNED-DURATION, X- (client defined), SCTE35-CMD, SCTE35-OUT, SCTE35-IN and END-ON-NEXT are defined.

EXT-X-KEY

Starting at revision 20 (version 7) it should provides milliseconds:

#EXT-X-PROGRAM-DATE-TIME:<YYYY-MM-DDThh:mm:ss.SSSZ>>

EXT-X-MAP

Made mandatory for MPEG-4 Fragmented (starting at revision 20).

Version 8

Note that there is no version 9.

IMSC subtitles

IMSC1. In MP4 only. Codec attribute is “stpp.ttml.im1t”.

Variable subtitution

Variable names are defined by the EXT-X-DEFINE tag and defined as {$VAR_NAME}.

EXT-X-GAP

The segment URL should not be loaded by clients because it applies to the next media segment.

EXT-X-STREAM-INF: VIDEO RANGE

The VIDEO RANGE attribute supports SDR and PQ transfer characteristics.

EXT-X-DEFINE:attribute

Optional tag to declare variable name, value, or derivation from the master playlist.

Version 10

Note that there is no version 9.

EXT-X-PART-INF:attribute-list

Information about partial segment. Only the “PART-TARGET” attribute is defined.

EXT-X-SERVER-CONTROL

Allows the Server to indicate support for “delivery directives” defined as optional attributes: CAN-SKIP-UNTIL, CAN-SKIP-DATERANGES, HOLD-BACK, PART-HOLD-BACK, CAN-BLOCK-RELOAD.

EXT-X-PART:attribute-list

Identifies a partial segment using attributes: URI, DURATION, INDEPENDENT, BYTERANGE, GAP.

EXT-X-SKIP: attribute-list

The server has replaced some tags to inform the client it is not relevant. This is completed by attributes: SKIPPED-SEGMENTS (count), RECENTLY-REMOVED-DATERANGES.

EXT-X-PRELOAD-HINT

Indicates resources that can be preloaded before being effectively available (in pratice the connection will be blocked until data is available). The hint on a partial segment may be signalled by the following attributes: TYPE, URI, BYTERANGE-START, BYTERANGE-LENGTH

EXT-X-RENDITION-REPORT

A report containing the URI, Media Sequence Number, and Part Index of the last Partial Segment, all expressed as attributes.

6 comments on “Apple HLS: technical in-depth”

  1. Pingback: Apple HLS: technical in-depth - GPAC Licensing ...

  2. Pingback: Streaming: The HLS Version 4 hype, and the whole truth about it #9 - Francesco Altomare – Cloud Architect

    • Romain Bouqueau Reply

      Thank you Leandro! At the moment we still sell trainings on MPEG-DASH to finance the GPAC open-source development. Let us know if we can help.

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php