RFC 8216

HTTP Live Streaming

๐Ÿ“… published August 2017, from ietf

Part 1 of 11 ๐ŸŽ€

HTTP Live Streaming ๐Ÿฆ‹

Okay bestie, this is RFC 8216, called HTTP Live Streaming ๐Ÿ’–. It's Informational, so it's published for information and isn't a Standards Track spec โœจ. It came in as an Independent Submission, which means it's not from any other RFC stream. R. Pantos, Ed. from Apple, Inc. is the editor, and W. May from MLB Advanced Media is the other author ๐Ÿซถ. It's dated August 2017, and its ISSN is 2070-1721. The header doesn't list anything it obsoletes or updates, so it's just doing its own thing ๐ŸŒธ.

Abstract

So this doc describes a protocol for sending unbounded streams of multimedia data ๐ŸŽฌ. It lays out the data format of the files, plus the actions the server (sender) and the clients (receivers) of those streams have to take. It describes version 7 of this protocol ๐Ÿ‘‘.

Status of This Memo

This doc is not an Internet Standards Track specification. It's just published for informational purposes ๐Ÿ’….

It's a contribution to the RFC Series, independent of any other RFC stream. The RFC Editor chose to publish it at their discretion, and they make no statement about how valuable it is for implementation or deployment. Docs the RFC Editor approves for publication aren't candidates for any level of Internet Standard, so check Section 2 of RFC 7841 if you want the deets ๐Ÿงš.

For the current status, any errata, and how to send feedback, look at http://www.rfc-editor.org/info/rfc8216 ๐Ÿ”—.

Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved ๐Ÿ’œ.

This doc is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as they were in effect on the date of publication. Please read those carefully, because they explain your rights and restrictions for this doc ๐Ÿ“œ.

This document may not be modified, and derivative works of it may not be created, except to format it for publication as an RFC or to translate it into languages other than English ๐Ÿšซ.

Table of Contents

   1. Introduction to HTTP Live Streaming .............................4
   2. Overview ........................................................4
   3. Media Segments ..................................................6
      3.1. Supported Media Segment Formats ............................6
      3.2. MPEG-2 Transport Streams ...................................7
      3.3. Fragmented MPEG-4 ..........................................7
      3.4. Packed Audio ...............................................8
      3.5. WebVTT .....................................................8
   4. Playlists .......................................................9
      4.1. Definition of a Playlist ..................................10
      4.2. Attribute Lists ...........................................11
      4.3. Playlist Tags .............................................12
           4.3.1. Basic Tags .........................................12
                  4.3.1.1. EXTM3U ....................................12
                  4.3.1.2. EXT-X-VERSION .............................12
           4.3.2. Media Segment Tags .................................13
                  4.3.2.1. EXTINF ....................................13
                  4.3.2.2. EXT-X-BYTERANGE ...........................14
                  4.3.2.3. EXT-X-DISCONTINUITY .......................14
                  4.3.2.4. EXT-X-KEY .................................15
                  4.3.2.5. EXT-X-MAP .................................17
                  4.3.2.6. EXT-X-PROGRAM-DATE-TIME ...................18
                  4.3.2.7. EXT-X-DATERANGE ...........................18
                           4.3.2.7.1. Mapping SCTE-35 into
                                      EXT-X-DATERANGE ................20
           4.3.3. Media Playlist Tags ................................22
                  4.3.3.1. EXT-X-TARGETDURATION ......................22
                  4.3.3.2. EXT-X-MEDIA-SEQUENCE ......................22
                  4.3.3.3. EXT-X-DISCONTINUITY-SEQUENCE ..............23
                  4.3.3.4. EXT-X-ENDLIST .............................23
                  4.3.3.5. EXT-X-PLAYLIST-TYPE .......................24
                  4.3.3.6. EXT-X-I-FRAMES-ONLY .......................24
           4.3.4. Master Playlist Tags ...............................25
                  4.3.4.1. EXT-X-MEDIA ...............................25
                           4.3.4.1.1. Rendition Groups ...............28
                  4.3.4.2. EXT-X-STREAM-INF ..........................29
                           4.3.4.2.1. Alternative Renditions .........32
                  4.3.4.3. EXT-X-I-FRAME-STREAM-INF ..................33
                  4.3.4.4. EXT-X-SESSION-DATA ........................34
                  4.3.4.5. EXT-X-SESSION-KEY .........................35
           4.3.5. Media or Master Playlist Tags ......................35
                  4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS ................35
                  4.3.5.2. EXT-X-START ...............................36

   5. Key Files ......................................................37
      5.1. Structure of Key Files ....................................37
      5.2. IV for AES-128 ............................................37
   6. Client/Server Responsibilities .................................37
      6.1. Introduction ..............................................37
      6.2. Server Responsibilities ...................................37
           6.2.1. General Server Responsibilities ....................37
           6.2.2. Live Playlists .....................................40
           6.2.3. Encrypting Media Segments ..........................41
           6.2.4. Providing Variant Streams ..........................42
      6.3. Client Responsibilities ...................................44
           6.3.1. General Client Responsibilities ....................44
           6.3.2. Loading the Media Playlist File ....................44
           6.3.3. Playing the Media Playlist File ....................45
           6.3.4. Reloading the Media Playlist File ..................46
           6.3.5. Determining the Next Segment to Load ...............47
           6.3.6. Decrypting Encrypted Media Segments ................47
   7. Protocol Version Compatibility .................................48
   8. Playlist Examples ..............................................50
      8.1. Simple Media Playlist .....................................50
      8.2. Live Media Playlist Using HTTPS ...........................50
      8.3. Playlist with Encrypted Media Segments ....................51
      8.4. Master Playlist ...........................................51
      8.5. Master Playlist with I-Frames .............................51
      8.6. Master Playlist with Alternative Audio ....................52
      8.7. Master Playlist with Alternative Video ....................52
      8.8. Session Data in a Master Playlist .........................53
      8.9. CHARACTERISTICS Attribute Containing Multiple
           Characteristics ...........................................54
      8.10. EXT-X-DATERANGE Carrying SCTE-35 Tags ....................54
   9. IANA Considerations ............................................54
   10. Security Considerations .......................................55
   11. References ....................................................56
      11.1. Normative References .....................................56
      11.2. Informative References ...................................59
   Contributors ......................................................60
   Authors' Addresses ................................................60

1. Introduction to HTTP Live Streaming โœจ

HTTP Live Streaming gives you a reliable, cost-effective way to deliver continuous, long-form video over the Internet ๐ŸŽฅ. A receiver can adapt the bit rate of the media to current network conditions, so playback stays uninterrupted at the best quality it can manage ๐Ÿ’ซ. It supports interstitial content boundaries ๐ŸŽ€. It gives you a flexible framework for media encryption ๐Ÿ”. It can offer multiple renditions of the same content efficiently, like audio translations ๐ŸŒ. And it's compatible with large-scale HTTP caching infrastructure, so it can reach big audiences ๐Ÿ“ฃ.

The Internet-Draft was first posted in 2009. Since then, HTTP Live Streaming has been implemented and deployed by a wide array of content producers, tools vendors, distributors, and device manufacturers ๐Ÿญ. Over the following eight years, the protocol was refined through extensive review and discussion with a variety of media streaming implementors ๐Ÿง .

The purpose of this document is to help HTTP Live Streaming implementations interoperate, by describing the media transmission protocol ๐Ÿค. With it, a client can receive a continuous stream of media from a server for concurrent presentation ๐ŸŽž๏ธ.

This document describes version 7 of the protocol ๐Ÿ‘‘.

2. Overview ๐ŸŒˆ

A multimedia presentation is specified by a Uniform Resource Identifier (URI) [RFC3986] that points to a Playlist ๐Ÿ”—.

A Playlist is either a Media Playlist or a Master Playlist. Both are UTF-8 text files containing URIs and descriptive tags ๐Ÿ“.

A Media Playlist contains a list of Media Segments. When you play them in sequence, you get the multimedia presentation ๐Ÿฟ.

Here is an example of a Media Playlist:

#EXTM3U
#EXT-X-TARGETDURATION:10

#EXTINF:9.009,
http://media.example.com/first.ts
#EXTINF:9.009,
http://media.example.com/second.ts
#EXTINF:3.003,
http://media.example.com/third.ts

The first line is the format identifier tag #EXTM3U ๐Ÿท๏ธ. The line with #EXT-X-TARGETDURATION says all Media Segments will be 10 seconds long or less โฑ๏ธ. Then three Media Segments get declared. The first and second are 9.009 seconds long, and the third is 3.003 seconds ๐ŸŽฌ.

To play this Playlist, the client downloads it first, then downloads and plays each Media Segment declared inside it. The client reloads the Playlist as described in this document to find any added segments ๐Ÿ”„. Data SHOULD be carried over HTTP [RFC7230], but in general, a URI can specify any protocol that can reliably transfer the specified resource on demand ๐Ÿ’Œ.

A more complex presentation can be described by a Master Playlist. A Master Playlist provides a set of Variant Streams, and each one describes a different version of the same content ๐Ÿงฉ.

A Variant Stream includes a Media Playlist that specifies media encoded at a particular bit rate, in a particular format, and at a particular resolution for media containing video ๐Ÿ“บ.

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

Clients should switch between different Variant Streams to adapt to network conditions ๐Ÿ“ถ. Clients should choose Renditions based on user preferences ๐Ÿ’โ€โ™€๏ธ.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. Those are the official rules words, so read them carefully ๐Ÿง.

3. Media Segments ๐ŸŽฌโœจ

okay so a Media Playlist is basically a lineup of Media Segments that together make up the whole presentation ๐ŸŽ€. Each Media Segment is pointed to by a URI and, optionally, a byte range ๐Ÿฆ‹.

The duration of each segment is written in the Media Playlist with its EXTINF tag (Section 4.3.2.1) ๐Ÿ’–.

Every segment in a Media Playlist gets its own unique integer Media Sequence Number ๐Ÿ”ข. The first segment's number is either 0 or declared in the Playlist (Section 4.3.3.2), and every other segment is just the one before it plus one. literally counting up, no cap ๐Ÿ’….

Each Media Segment MUST carry on the encoded bitstream from where the segment with the previous Media Sequence Number ended ๐Ÿซถ. Values like timestamps and Continuity Counters MUST keep going uninterrupted. The only exceptions are the very first Media Segment ever to appear in a Media Playlist, and segments that are explicitly signaled as discontinuities (Section 4.3.2.3). Unmarked media discontinuities can trigger playback errors ๐Ÿ˜ญ.

Any Media Segment that contains video SHOULD include enough information to initialize a video decoder and decode a continuous set of frames that includes the final frame in the Segment. Network efficiency is optimized if there is enough info in the Segment to decode all frames in it ๐Ÿš€. For example, any Media Segment containing H.264 video SHOULD contain an Instantaneous Decoding Refresh (IDR). Frames before the first IDR will be downloaded but possibly discarded ๐Ÿ™ˆ.

3.1. Supported Media Segment Formats ๐Ÿ—‚๏ธ

All Media Segments MUST be in a format described in this section. Transport of other media file formats is not defined.

Some media formats need a common sequence of bytes to set up a parser before a Media Segment can be parsed. That format-specific sequence is called the Media Initialization Section, and it can be specified by an EXT-X-MAP tag (Section 4.3.2.5). The Media Initialization Section MUST NOT contain sample data ๐Ÿ™….

3.2. MPEG-2 Transport Streams ๐Ÿ“ผ

MPEG-2 Transport Streams are specified by [ISO_13818].

The Media Initialization Section of an MPEG-2 Transport Stream Segment is a Program Association Table (PAT) followed by a Program Map Table (PMT).

Transport Stream Segments MUST contain a single MPEG-2 Program. Playback of Multi-Program Transport Streams is not defined. Each Transport Stream Segment MUST contain a PAT and a PMT, or have an EXT-X-MAP tag (Section 4.3.2.5) applied to it. The first two Transport Stream packets in a Segment without an EXT-X-MAP tag SHOULD be a PAT and a PMT.

3.3. Fragmented MPEG-4 ๐Ÿงฉ

MPEG-4 Fragments are specified by the ISO Base Media File Format [ISOBMFF]. Regular MPEG-4 files have a Movie Box ('moov') that holds sample tables, plus a Media Data Box ('mdat') with the matching samples. An MPEG-4 Fragment is different: it has a Movie Fragment Box ('moof') holding a subset of the sample table, and a Media Data Box holding those samples. Fragments still need a Movie Box for initialization, but that Movie Box only has non-sample-specific info, like track and sample descriptions.

A Fragmented MPEG-4 (fMP4) Segment is a "segment" as defined by Section 3 of [ISOBMFF], including the constraints on Media Data Boxes in Section 8.16 of [ISOBMFF].

The Media Initialization Section for an fMP4 Segment is an ISO Base Media File that can initialize a parser for that Segment.

Broadly speaking, fMP4 Segments and Media Initialization Sections are [ISOBMFF] files that also satisfy the constraints described in this section.

The Media Initialization Section for an fMP4 Segment MUST contain a File Type Box ('ftyp') containing a brand that is compatible with 'iso6' or higher. The File Type Box MUST be followed by a Movie Box. The Movie Box MUST contain a Track Box ('trak') for every Track Fragment Box ('traf') in the fMP4 Segment, with matching track_ID. Each Track Box SHOULD contain a sample table, but its sample count MUST be zero. Movie Header Boxes ('mvhd') and Track Header Boxes ('tkhd') MUST have durations of zero. A Movie Extends Box ('mvex') MUST follow the last Track Box. Note that a Common Media Application Format (CMAF) Header [CMAF] meets all these requirements.

In an fMP4 Segment, every Track Fragment Box MUST contain a Track Fragment Decode Time Box ('tfdt'). fMP4 Segments MUST use movie-fragment-relative addressing. fMP4 Segments MUST NOT use external data references. Note that a CMAF Segment meets these requirements.

An fMP4 Segment in a Playlist containing the EXT-X-I-FRAMES-ONLY tag (Section 4.3.3.6) MAY omit the portion of the Media Data Box following the intra-coded frame (I-frame) sample data.

Each fMP4 Segment in a Media Playlist MUST have an EXT-X-MAP tag applied to it.

3.4. Packed Audio ๐ŸŽง

A Packed Audio Segment contains encoded audio samples and ID3 tags that are simply packed together with minimal framing and no per-sample timestamps. The supported Packed Audio formats are Advanced Audio Coding (AAC) with Audio Data Transport Stream (ADTS) framing [ISO_13818_7], MP3 [ISO_13818_3], AC-3 [AC_3], and Enhanced AC-3 [AC_3].

A Packed Audio Segment has no Media Initialization Section.

Each Packed Audio Segment MUST signal the timestamp of its first sample with an ID3 Private frame (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. Clients SHOULD NOT play Packed Audio Segments without this ID3 tag ๐Ÿ™…โ€โ™€๏ธ.

3.5. WebVTT ๐Ÿ’ฌ

A WebVTT Segment is a section of a WebVTT [WebVTT] file. WebVTT Segments carry subtitles.

The Media Initialization Section of a WebVTT Segment is the WebVTT header.

Each WebVTT Segment MUST contain all subtitle cues that are intended to be displayed during the period indicated by the segment EXTINF duration. The start time offset and end time offset of each cue MUST indicate the total display time for that cue, even if part of the cue time range is outside the Segment period. A WebVTT Segment MAY contain no cues. That just means no subtitles are to be displayed during that period ๐Ÿคซ.

Each WebVTT Segment MUST either start with a WebVTT header or have an EXT-X-MAP tag applied to it.

In order to synchronize timestamps between audio/video and subtitles, an X-TIMESTAMP-MAP metadata header SHOULD be added to each WebVTT header. This header maps WebVTT cue timestamps to MPEG-2 (PES) timestamps in other Renditions of the Variant Stream. Its format is:

X-TIMESTAMP-MAP=LOCAL:<cue time>,MPEGTS:<MPEG-2 time>
e.g., X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

The cue timestamp in the LOCAL attribute MAY fall outside the range of time covered by the segment.

If a WebVTT segment does not have the X-TIMESTAMP-MAP, the client MUST assume that the WebVTT cue time of 0 maps to an MPEG-2 timestamp of 0.

When synchronizing WebVTT with PES timestamps, clients SHOULD account for cases where the 33-bit PES timestamps have wrapped and the WebVTT cue times have not. โฐ

4. Playlists ๐Ÿ“œ

This section describes the Playlist files used by HTTP Live Streaming. In this section, "MUST" and "MUST NOT" specify the rules for the syntax and structure of legal Playlist files. Playlists that violate these rules are invalid, and clients MUST fail to parse them. See Section 6.3.2.

The format of the Playlist files is derived from the M3U [M3U] playlist file format, and it inherits two tags from that earlier file format: EXTM3U (Section 4.3.1.1) and EXTINF (Section 4.3.2.1).

In the specification of tag syntax, a string enclosed by <> identifies a tag parameter. Its specific format is described in its tag definition. If a parameter is further surrounded by [], it is optional. Otherwise, it is required ๐Ÿงพ.

Each Playlist file MUST be identifiable either by the path component of its URI or by HTTP Content-Type. In the first case, the path MUST end with either .m3u8 or .m3u. In the second, the HTTP Content-Type MUST be "application/vnd.apple.mpegurl" or "audio/mpegurl". Clients SHOULD refuse to parse Playlists that are not so identified.

4.1. Definition of a Playlist ๐Ÿ”

Playlist files MUST be encoded in UTF-8 [RFC3629]. They MUST NOT contain any Byte Order Mark (BOM). Clients SHOULD fail to parse Playlists that contain a BOM or do not parse as UTF-8. Playlist files MUST NOT contain UTF-8 control characters (U+0000 to U+001F and U+007F to U+009F), with the exceptions of CR (U+000D) and LF (U+000A). All character sequences MUST be normalized according to Unicode normalization form "NFC" [UNICODE]. Note that US-ASCII [US_ASCII] conforms to these rules.

Lines in a Playlist file are terminated by either a single line feed character or a carriage return character followed by a line feed character. Each line is a URI, is blank, or starts with the character '#'. Blank lines are ignored. Whitespace MUST NOT be present, except for elements in which it is explicitly specified.

Lines that start with the character '#' are either comments or tags. Tags begin with #EXT, and they are case sensitive. All other lines that begin with '#' are comments and SHOULD be ignored.

A URI line identifies a Media Segment or a Playlist file (see Section 4.3.4.2). Each Media Segment is specified by a URI and the tags that apply to it.

A Playlist is a Media Playlist if all URI lines in the Playlist identify Media Segments. A Playlist is a Master Playlist if all URI lines in the Playlist identify Media Playlists. A Playlist MUST be either a Media Playlist or a Master Playlist. All other Playlists are invalid.

A URI in a Playlist, whether it is a URI line or part of a tag, MAY be relative. Any relative URI is considered to be relative to the URI of the Playlist that contains it.

The duration of a Media Playlist is the sum of the durations of the Media Segments within it.

The segment bit rate of a Media Segment is the size of the Media Segment divided by its EXTINF duration (Section 4.3.2.1). Note that this includes container overhead but does not include overhead imposed by the delivery system, such as HTTP, TCP, or IP headers.

The peak segment bit rate of a Media Playlist is the largest bit rate of any contiguous set of segments whose total duration is between 0.5 and 1.5 times the target duration. The bit rate of a set is calculated by dividing the sum of the segment sizes by the sum of the segment durations ๐Ÿ“ˆ.

The average segment bit rate of a Media Playlist is the sum of the sizes (in bits) of every Media Segment in the Media Playlist, divided by the Media Playlist duration. Note that this includes container overhead, but not HTTP or other overhead imposed by the delivery system.

4.2. Attribute Lists ๐Ÿ’…

okay so certain tags have values that are attribute-lists ๐ŸŽ€. An attribute-list is a comma-separated list of attribute/value pairs with no whitespace at all (not even a little bit ๐Ÿ™ˆ).

An attribute/value pair looks like this:

AttributeName=AttributeValue

An AttributeName is an unquoted string made of characters from the set [A..Z], [0..9] and -. So AttributeNames are uppercase only, never lowercase ๐Ÿ”  no exceptions, periodt. There MUST NOT be any whitespace between the AttributeName and the = character, nor between the = character and the AttributeValue. Keep it tight, bestie ๐Ÿซถ

An AttributeValue is one of the following:

  • decimal-integer: an unquoted string of characters from the set [0..9] expressing an integer in base-10 arithmetic in the range from 0 to 2^64-1 (18446744073709551615). A decimal-integer may be from 1 to 20 characters long. ๐Ÿ”ข
  • hexadecimal-sequence: an unquoted string of characters from the set [0..9] and [A..F] that is prefixed with 0x or 0X. The maximum length of a hexadecimal-sequence depends on its AttributeNames. ๐Ÿงฉ
  • decimal-floating-point: an unquoted string of characters from the set [0..9] and . that expresses a non-negative floating-point number in decimal positional notation. ๐ŸŒธ
  • signed-decimal-floating-point: an unquoted string of characters from the set [0..9], -, and . that expresses a signed floating-point number in decimal positional notation. โž•โž–
  • quoted-string: a string of characters within a pair of double quotes (0x22). The following characters MUST NOT appear in a quoted-string: line feed (0xA), carriage return (0xD), or double quote (0x22). Quoted-string AttributeValues SHOULD be constructed so that byte-wise comparison is sufficient to test two quoted-string AttributeValues for equality. Note that this implies case-sensitive comparison. ๐ŸŽฏ
  • enumerated-string: an unquoted character string from a set that is explicitly defined by the AttributeName. An enumerated-string will never contain double quotes ("), commas (,), or whitespace. ๐Ÿ“‹
  • decimal-resolution: two decimal-integers separated by the "x" character. The first integer is a horizontal pixel dimension (width); the second is a vertical pixel dimension (height). ๐Ÿ“บ

The type of the AttributeValue for a given AttributeName is specified by the attribute definition. So always check the definition, iykyk ๐Ÿ‘€

A given AttributeName MUST NOT appear more than once in a given attribute-list. Clients SHOULD refuse to parse such Playlists. ๐Ÿšซ like, that's a hard no from me ๐Ÿ’€


4.3. Playlist Tags ๐ŸŽ€

Playlist tags are the main character of this whole thing โœจ they specify either global parameters of the Playlist or information about the Media Segments or Media Playlists that appear after them.

4.3.1. Basic Tags ๐Ÿงš

These tags are allowed in both Media Playlists and Master Playlists. Sharing is caring ๐Ÿ’œ

4.3.1.1. EXTM3U ๐Ÿ“

The EXTM3U tag indicates that the file is an Extended M3U [M3U] Playlist file. It MUST be the first line of every Media Playlist and every Master Playlist. Its format is:

#EXTM3U

4.3.1.2. EXT-X-VERSION ๐Ÿ”ข

The EXT-X-VERSION tag indicates the compatibility version of the Playlist file, its associated media, and its server. It applies to the entire Playlist file, so it's a whole vibe ๐ŸŒˆ Its format is:

#EXT-X-VERSION:<n>

where n is an integer indicating the protocol compatibility version number.

It MUST appear in all Playlists containing tags or attributes that are not compatible with protocol version 1, so older clients can still keep up and interoperate ๐Ÿซถ [Section 7] specifies the minimum value of the compatibility version number for any given Playlist file.

A Playlist file MUST NOT contain more than one EXT-X-VERSION tag. If a client encounters a Playlist with multiple EXT-X-VERSION tags, it MUST fail to parse it. Two version tags is a crime scene ๐Ÿšจ the client has to bail.

4.3.2. Media Segment Tags ๐ŸŽฌ

Each Media Segment is specified by a series of Media Segment tags followed by a URI. Some Media Segment tags only apply to the next segment, and others apply to all subsequent segments until another instance of the same tag shows up ๐Ÿ”

A Media Segment tag MUST NOT appear in a Master Playlist. Clients MUST fail to parse Playlists that contain both Media Segment tags and Master Playlist tags (Section 4.3.4). Don't mix your lanes, bestie ๐Ÿš—๐Ÿ’จ

4.3.2.1. EXTINF โฑ๏ธ

The EXTINF tag specifies the duration of a Media Segment. It applies only to the next Media Segment. This tag is REQUIRED for each Media Segment. Its format is:

#EXTINF:<duration>,[<title>]

where duration is a decimal-floating-point or decimal-integer number (as described in Section 4.2) that specifies the duration of the Media Segment in seconds. Durations SHOULD be decimal-floating-point, with enough accuracy to avoid perceptible error when segment durations are accumulated. However, if the compatibility version number is less than 3, durations MUST be integers. Durations that are reported as integers SHOULD be rounded to the nearest integer. The remainder of the line following the comma is an optional human-readable informative title of the Media Segment expressed as UTF-8 text. โœ๏ธ the title is extra tea, not a must ๐Ÿต

4.3.2.2. EXT-X-BYTERANGE ๐Ÿ“ฆ

The EXT-X-BYTERANGE tag indicates that a Media Segment is a sub-range of the resource identified by its URI. It applies only to the next URI line that follows it in the Playlist. Its format is:

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

where n is a decimal-integer indicating the length of the sub-range in bytes. If present, o is a decimal-integer indicating the start of the sub-range, as a byte offset from the beginning of the resource. If o is not present, the sub-range begins at the next byte following the sub-range of the previous Media Segment. ๐Ÿงฎ

If o is not present, a previous Media Segment MUST appear in the Playlist file and MUST be a sub-range of the same media resource, or the Media Segment is undefined and the client MUST fail to parse the Playlist. No previous segment, no cap, the whole thing collapses ๐Ÿ’€

A Media Segment without an EXT-X-BYTERANGE tag consists of the entire resource identified by its URI. Simple and iconic ๐Ÿ‘‘

Use of the EXT-X-BYTERANGE tag REQUIRES a compatibility version number of 4 or greater. ๐Ÿ”‘

4.3.2.3. EXT-X-DISCONTINUITY โšก

The EXT-X-DISCONTINUITY tag indicates a discontinuity between the Media Segment that follows it and the one that preceded it. It's giving "plot twist" energy ๐ŸŽญ

Its format is:

#EXT-X-DISCONTINUITY

The EXT-X-DISCONTINUITY tag MUST be present if there is a change in any of the following characteristics:

  • file format
  • number, type, and identifiers of tracks
  • timestamp sequence

The EXT-X-DISCONTINUITY tag SHOULD be present if there is a change in any of the following characteristics:

  • encoding parameters
  • encoding sequence

See Sections 3, 6.2.1, and 6.3.3 for more information about the EXT-X-DISCONTINUITY tag. ๐Ÿ“š bookmark that one, bestie ๐Ÿ”–

4.3.2.4. EXT-X-KEY ๐Ÿ”

Media Segments MAY be encrypted. The EXT-X-KEY tag specifies how to decrypt them. It applies to every Media Segment and to every Media Initialization Section declared by an EXT-X-MAP tag that appears between it and the next EXT-X-KEY tag in the Playlist file with the same KEYFORMAT attribute (or the end of the Playlist file). Two or more EXT-X-KEY tags with different KEYFORMAT attributes MAY apply to the same Media Segment if they ultimately produce the same decryption key. The format is:

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

The following attributes are defined: ๐Ÿ—๏ธ

METHOD

The value is an enumerated-string that specifies the encryption method. This attribute is REQUIRED.

The methods defined are: NONE, AES-128, and SAMPLE-AES.

An encryption method of NONE means that Media Segments are not encrypted. If the encryption method is NONE, other attributes MUST NOT be present. ๐Ÿ™…โ€โ™€๏ธ

An encryption method of AES-128 signals that Media Segments are completely encrypted using the Advanced Encryption Standard (AES) [AES_128] with a 128-bit key, Cipher Block Chaining (CBC), and Public-Key Cryptography Standards #7 (PKCS7) padding [RFC5652]. CBC is restarted on each segment boundary, using either the Initialization Vector (IV) attribute value or the Media Sequence Number as the IV; see Section 5.2. ๐Ÿ”’โœจ

An encryption method of SAMPLE-AES means that the Media Segments contain media samples, such as audio or video, that are encrypted using the Advanced Encryption Standard [AES_128]. How these media streams are encrypted and encapsulated in a segment depends on the media encoding and the media format of the segment. fMP4 Media Segments are encrypted using the 'cbcs' scheme of Common Encryption [COMMON_ENC]. Encryption of other Media Segment formats containing H.264 [H_264], AAC [ISO_14496], AC-3 [AC_3], and Enhanced AC-3 [AC_3] media streams is described in the HTTP Live Streaming (HLS) Sample Encryption specification [SampleEnc]. The IV attribute MAY be present; see Section 5.2. ๐ŸŽž๏ธ

URI

The value is a quoted-string containing a URI that specifies how to obtain the key. This attribute is REQUIRED unless the METHOD is NONE. ๐Ÿ”—

IV

The value is a hexadecimal-sequence that specifies a 128-bit unsigned integer Initialization Vector to be used with the key. Use of the IV attribute REQUIRES a compatibility version number of 2 or greater. See Section 5.2 for when the IV attribute is used. ๐Ÿง

KEYFORMAT

The value is a quoted-string that specifies how the key is represented in the resource identified by the URI; see Section 5 for more detail. This attribute is OPTIONAL; its absence indicates an implicit value of "identity". Use of the KEYFORMAT attribute REQUIRES a compatibility version number of 5 or greater. ๐Ÿชช

KEYFORMATVERSIONS

The value is a quoted-string containing one or more positive integers separated by the "/" character (for example, "1", "1/2", or "1/2/5"). If more than one version of a particular KEYFORMAT is defined, this attribute can be used to indicate which version(s) this instance complies with. This attribute is OPTIONAL; if it is not present, its value is considered to be "1". Use of the KEYFORMATVERSIONS attribute REQUIRES a compatibility version number of 5 or greater. ๐Ÿท๏ธ

If the Media Playlist file does not contain an EXT-X-KEY tag, then Media Segments are not encrypted. Plain and simple ๐ŸŒท

See Section 5 for the format of the Key file and Sections 5.2, 6.2.3, and 6.3.6 for additional information on Media Segment encryption. ๐Ÿ”๐Ÿ’–

4.3.2.5. EXT-X-MAP ๐Ÿ—บ๏ธ

okay bestie, EXT-X-MAP is the tag that tells your player where to find the Media Initialization Section (Section 3) so it can parse the Media Segments ๐ŸŽ€. It applies to every Media Segment after it in the Playlist until the next EXT-X-MAP tag or the end of the Playlist. so iconic ๐Ÿ’…

Its format is:

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

Here are the attributes it defines:

  • URI: a quoted-string containing a URI that points to a resource holding the Media Initialization Section. This attribute is REQUIRED. ๐Ÿ”—
  • BYTERANGE: a quoted-string giving a byte range into the resource that the URI attribute identifies. This range SHOULD contain only the Media Initialization Section. The byte range format is described in Section 4.3.2.2. This one is OPTIONAL. If it isn't there, the byte range is the entire resource at the URI ๐Ÿงš

An EXT-X-MAP tag SHOULD be supplied for Media Segments in Playlists with the EXT-X-I-FRAMES-ONLY tag when the first Media Segment (i.e., I-frame) in the Playlist (or the first segment after an EXT-X-DISCONTINUITY tag) does not immediately follow the Media Initialization Section at the start of its resource. ๐Ÿฆ‹

Using EXT-X-MAP in a Media Playlist that has the EXT-X-I-FRAMES-ONLY tag REQUIRES a compatibility version number of 5 or greater. Using it in a Media Playlist that does not contain the EXT-X-I-FRAMES-ONLY tag REQUIRES a compatibility version number of 6 or greater. ๐ŸŒธ

If the Media Initialization Section declared by an EXT-X-MAP tag is encrypted with a METHOD of AES-128, then the IV attribute of the EXT-X-KEY tag that applies to the EXT-X-MAP is REQUIRED. don't skip this one, bestie ๐Ÿ˜ญ

4.3.2.6. EXT-X-PROGRAM-DATE-TIME โฐ

The EXT-X-PROGRAM-DATE-TIME tag ties the first sample of a Media Segment to an absolute date and/or time. It only applies to the next Media Segment. Its format is:

#EXT-X-PROGRAM-DATE-TIME:<date-time-msec>

where date-time-msec is an ISO/IEC 8601:2004 [ISO_8601] date/time representation, such as YYYY-MM-DDThh:mm:ss.SSSZ. It SHOULD indicate a time zone and fractional parts of seconds, to millisecond accuracy. โœจ

For example:

#EXT-X-PROGRAM-DATE-TIME:2010-02-19T14:54:23.031+08:00

See Sections 6.2.1 and 6.3.3 for more information on the EXT-X-PROGRAM-DATE-TIME tag. ๐Ÿ’œ

4.3.2.7. EXT-X-DATERANGE ๐Ÿ“…

The EXT-X-DATERANGE tag links a Date Range (a span of time defined by a starting and ending date) to a set of attribute/value pairs. Its format is:

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

Here are the defined attributes, and they're a lot ๐Ÿ‘‘

  • ID: a quoted-string that uniquely identifies a Date Range in the Playlist. This attribute is REQUIRED.
  • CLASS: a client-defined quoted-string that specifies a set of attributes and their associated value semantics. All Date Ranges with the same CLASS attribute value MUST adhere to these semantics. This attribute is OPTIONAL.
  • START-DATE: a quoted-string containing the ISO-8601 date at which the Date Range begins. This attribute is REQUIRED.
  • END-DATE: a quoted-string containing the ISO-8601 date at which the Date Range ends. It MUST be equal to or later than the value of the START-DATE attribute. This attribute is OPTIONAL.
  • DURATION: the duration of the Date Range, expressed as a decimal-floating-point number of seconds. It MUST NOT be negative. A single instant in time (e.g., crossing a finish line) SHOULD be represented with a duration of 0. This attribute is OPTIONAL.
  • PLANNED-DURATION: the expected duration of the Date Range, expressed as a decimal-floating-point number of seconds. It MUST NOT be negative. This attribute SHOULD be used to indicate the expected duration of a Date Range whose actual duration isn't known yet. It is OPTIONAL.
  • X-<client-attribute>: the "X-" prefix is a namespace reserved for client-defined attributes. The client-attribute MUST be a legal AttributeName. Clients SHOULD use a reverse-DNS syntax when defining their own attribute names to avoid collisions. The attribute value MUST be a quoted-string, a hexadecimal-sequence, or a decimal-floating-point. An example of a client-defined attribute is X-COM-EXAMPLE-AD-ID="XYZ123". These attributes are OPTIONAL. ๐Ÿง
  • SCTE35-CMD, SCTE35-OUT, SCTE35-IN: used to carry SCTE-35 data. See Section 4.3.2.7.1 for more information. These attributes are OPTIONAL.
  • END-ON-NEXT: an enumerated-string whose value MUST be YES. This attribute indicates that the end of the range containing it is equal to the START-DATE of its Following Range. The Following Range is the Date Range of the same CLASS that has the earliest START-DATE after the START-DATE of the range in question. This attribute is OPTIONAL.

An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST have a CLASS attribute. Other EXT-X-DATERANGE tags with the same CLASS attribute MUST NOT specify Date Ranges that overlap. ๐Ÿšซ

An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.

A Date Range with none of a DURATION, an END-DATE, or an END-ON-NEXT=YES attribute has an unknown duration, even if it has a PLANNED-DURATION.

If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.

If a Playlist contains two EXT-X-DATERANGE tags with the same ID attribute value, then any AttributeName that appears in both tags MUST have the same AttributeValue.

If a Date Range contains both a DURATION attribute and an END-DATE attribute, the value of the END-DATE attribute MUST be equal to the value of the START-DATE attribute plus the value of the DURATION attribute. ๐Ÿงฎ

Clients SHOULD ignore EXT-X-DATERANGE tags with illegal syntax. ๐Ÿ™ˆ

4.3.2.7.1. Mapping SCTE-35 into EXT-X-DATERANGE ๐Ÿ“บ

Splice information carried in source media according to the SCTE-35 specification [SCTE35] MAY be represented in a Media Playlist using EXT-X-DATERANGE tags. ๐ŸŽฌ

Each SCTE-35 splice_info_section() containing a splice_null(), splice_schedule(), bandwidth_reservation(), or private_cmd() SHOULD be represented by an EXT-X-DATERANGE tag with an SCTE35-CMD attribute. That attribute's value is the big-endian binary representation of the splice_info_section(), expressed as a hexadecimal-sequence.

An SCTE-35 splice out/in pair signaled by a pair of splice_insert() commands SHOULD be represented by one or more EXT-X-DATERANGE tags carrying the same ID attribute. That ID MUST be unique to that splice out/in pair. The "out" splice_info_section() (with out_of_network_indicator set to 1) MUST be placed in an SCTE35-OUT attribute, formatted the same way as SCTE35-CMD. The "in" splice_info_section() (with out_of_network_indicator set to 0) MUST be placed in an SCTE35-IN attribute, formatted the same way as SCTE35-CMD. ๐Ÿฆ‹

An SCTE-35 splice out/in pair signaled by a pair of time_signal() commands, each carrying a single segmentation_descriptor(), SHOULD be represented by one or more EXT-X-DATERANGE tags carrying the same ID attribute. That ID MUST be unique to that splice out/in pair. The "out" splice_info_section() MUST be placed in an SCTE35-OUT attribute. The "in" splice_info_section() MUST be placed in an SCTE35-IN attribute.

Different types of segmentation, as indicated by the segmentation_type_id in the segmentation_descriptor(), SHOULD be represented by separate EXT-X-DATERANGE tags, even if two or more segmentation_descriptor()s arrive in the same splice_info_section(). In that case, each EXT-X-DATERANGE tag will have an SCTE35-OUT, SCTE35-IN, or SCTE35-CMD attribute whose value is the entire splice_info_section(). ๐Ÿ“

An SCTE-35 time_signal() command that doesn't signal a splice out or in point SHOULD be represented by an EXT-X-DATERANGE tag with an SCTE35-CMD attribute.

The START-DATE of an EXT-X-DATERANGE tag containing an SCTE35-OUT attribute MUST be the date and time that corresponds to the program time of that splice.

The START-DATE of an EXT-X-DATERANGE tag containing an SCTE35-CMD MUST be the date and time specified by the splice_time() in the command, or the program time at which the command appeared in the source stream if the command doesn't specify a splice_time(). โณ

An EXT-X-DATERANGE tag containing an SCTE35-OUT attribute MAY contain a PLANNED-DURATION attribute. Its value MUST be the planned duration of the splice.

The DURATION of an EXT-X-DATERANGE tag containing an SCTE35-IN attribute MUST be the actual (not planned) program duration between the corresponding out-point and that in-point.

The END-DATE of an EXT-X-DATERANGE tag containing an SCTE35-IN attribute MUST be the actual (not planned) program date and time of that in-point.

If the actual end date and time isn't known when an SCTE35-OUT attribute is added to the Playlist, then the DURATION attribute and the END-TIME attribute MUST NOT be present. The actual end date of the splice SHOULD be signaled by another EXT-X-DATERANGE tag once it has been established. ๐Ÿ•ฐ๏ธ

A canceled splice SHOULD NOT appear in the Playlist as an EXT-X-DATERANGE tag.

An EXT-X-DATERANGE tag announcing a splice SHOULD be added to a Playlist at the same time as the last pre-splice Media Segment, or earlier if possible.

The ID attribute of an EXT-X-DATERANGE tag MAY contain a splice_event_id and/or a segmentation_event_id, but it MUST be unique in the Playlist. If there's a possibility that an SCTE-35 id will be reused, the ID attribute value MUST include disambiguation, such as a date or sequence number. ๐Ÿง 


4.3.3. Media Playlist Tags ๐ŸŽ€

Media Playlist tags describe the global parameters of the Media Playlist. There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist.

A Media Playlist tag MUST NOT appear in a Master Playlist. ๐Ÿ™…โ€โ™€๏ธ

4.3.3.1. EXT-X-TARGETDURATION ๐ŸŽฏ

The EXT-X-TARGETDURATION tag specifies the maximum Media Segment duration. The EXTINF duration of each Media Segment in the Playlist file, when rounded to the nearest integer, MUST be less than or equal to the target duration. Longer segments can trigger playback stalls or other errors, so be careful ๐Ÿ˜ฌ It applies to the entire Playlist file. Its format is:

#EXT-X-TARGETDURATION:<s>

where s is a decimal-integer indicating the target duration in seconds. The EXT-X-TARGETDURATION tag is REQUIRED. ๐Ÿ’–

4.3.3.2. EXT-X-MEDIA-SEQUENCE ๐Ÿ”ข

The EXT-X-MEDIA-SEQUENCE tag indicates the Media Sequence Number of the first Media Segment that appears in a Playlist file. Its format is:

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

where number is a decimal-integer.

If the Media Playlist file does not contain an EXT-X-MEDIA-SEQUENCE tag, then the Media Sequence Number of the first Media Segment in the Media Playlist SHALL be considered to be 0. A client MUST NOT assume that segments with the same Media Sequence Number in different Media Playlists contain matching content (see Section 6.3.2). ๐Ÿ™…

A URI for a Media Segment is not required to contain its Media Sequence Number.

See Sections 6.2.1 and 6.3.5 for more information on setting the EXT-X-MEDIA-SEQUENCE tag.

The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist. ๐Ÿซถ

4.3.3.3. EXT-X-DISCONTINUITY-SEQUENCE โœจ

okay so EXT-X-DISCONTINUITY-SEQUENCE is the tag that lets different Renditions of the same Variant Stream line up, and lets different Variant Streams line up too, as long as their Media Playlists have EXT-X-DISCONTINUITY tags ๐Ÿ’…

Its format is:

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

where number is a decimal-integer ๐ŸŽ€

if the Media Playlist doesn't have an EXT-X-DISCONTINUITY-SEQUENCE tag, the Discontinuity Sequence Number of the first Media Segment in the Playlist SHALL be considered to be 0 ๐ŸŒธ

the tag MUST show up before the first Media Segment in the Playlist ๐Ÿซถ

and it MUST show up before any EXT-X-DISCONTINUITY tag too, no exceptions bestie ๐Ÿ˜ญ

for how to actually set this value, check out Sections 6.2.1 and 6.2.2 ๐Ÿ“–

4.3.3.4. EXT-X-ENDLIST ๐Ÿฆ‹

the EXT-X-ENDLIST tag says "no more Media Segments are getting added to this Media Playlist file, we're done here" ๐Ÿ It MAY show up anywhere in the Media Playlist file. Its format is:

#EXT-X-ENDLIST

4.3.3.5. EXT-X-PLAYLIST-TYPE ๐Ÿงš

this one tells you how mutable the Media Playlist file is ๐Ÿ‘€ It applies to the whole Media Playlist file, and it is OPTIONAL. Its format is:

#EXT-X-PLAYLIST-TYPE:<type-enum>

where type-enum is either EVENT or VOD ๐Ÿ’œ

Section 6.2.1 spells out what this tag implies.

  • if the value is EVENT, Media Segments can only be added to the end of the Media Playlist ๐Ÿ“
  • if the value is Video On Demand (VOD), the Media Playlist cannot change at all ๐Ÿ”’

if you leave EXT-X-PLAYLIST-TYPE out, the Playlist can be updated under the rules in Section 6.2.1 with no extra restrictions. Like, a live Playlist (Section 6.2.2) MAY be updated to remove Media Segments in the order they appeared ๐ŸŒˆ

4.3.3.6. EXT-X-I-FRAMES-ONLY ๐Ÿ“

the EXT-X-I-FRAMES-ONLY tag means every Media Segment in the Playlist describes a single I-frame โœจ I-frames are encoded video frames whose encoding doesn't depend on any other frame, so they're totally self-contained ๐Ÿ™ˆ I-frame Playlists are great for trick play, like fast forward, rapid reverse, and scrubbing โฉ

it applies to the whole Playlist, and its format is:

#EXT-X-I-FRAMES-ONLY

in a Playlist with this tag, the Media Segment duration (the EXTINF tag value) is the time between the presentation time of the I-frame in that Media Segment and the presentation time of the next I-frame in the Playlist. If it's the last I-frame in the Playlist, the duration runs until the end of the presentation ๐ŸŽฌ

now the important bit ๐Ÿšจ

media resources with I-frame segments MUST either begin with a Media Initialization Section (Section 3), or come with an EXT-X-MAP tag that points at the Media Initialization Section. That's how clients can load and decode I-frame segments in any order ๐Ÿ”ฅ

the byte range of an I-frame segment that has an EXT-X-BYTERANGE tag applied (Section 4.3.2.2) MUST NOT include its Media Initialization Section. Clients can assume the Media Initialization Section is defined by the EXT-X-MAP tag, or that it sits from the start of the resource up to the offset of the first I-frame segment in that resource ๐Ÿ’–

and using EXT-X-I-FRAMES-ONLY REQUIRES a compatibility version number of 4 or greater ๐Ÿ”ข


4.3.4. Master Playlist Tags ๐Ÿ‘‘

Master Playlist tags are the ones that define the Variant Streams, the Renditions, and the other global parameters of the presentation. They're the main character of the whole file ๐Ÿ’…

Master Playlist tags MUST NOT appear in a Media Playlist. Also, clients MUST fail to parse any Playlist that has both a Master Playlist tag and either a Media Playlist tag or a Media Segment tag. Not allowed, periodt ๐Ÿ™…โ€โ™€๏ธ

4.3.4.1. EXT-X-MEDIA ๐ŸŽง

the EXT-X-MEDIA tag relates Media Playlists that hold alternative Renditions (Section 4.3.4.2.1) of the same content. For example, three EXT-X-MEDIA tags can identify audio-only Media Playlists with English, French, and Spanish Renditions of the same presentation ๐ŸŒ Or two of them can identify video-only Media Playlists showing two different camera angles ๐Ÿ“น

its format is:

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

here are the attributes you can use ๐Ÿซถ

TYPE ๐ŸŽฌ

the value is an enumerated-string, and the valid strings are AUDIO, VIDEO, SUBTITLES, and CLOSED-CAPTIONS. This attribute is REQUIRED.

typically, closed-caption [CEA608] media is carried inside the video stream. So an EXT-X-MEDIA tag with TYPE CLOSED-CAPTIONS does NOT specify a Rendition. The closed-caption media is just present in the Media Segments of every video Rendition ๐Ÿ“บ

URI ๐Ÿ”—

the value is a quoted-string holding a URI that identifies the Media Playlist file. This attribute is OPTIONAL. See Section 4.3.4.2.1. If the TYPE is CLOSED-CAPTIONS, the URI attribute MUST NOT be present ๐Ÿ™…

GROUP-ID ๐Ÿงฉ

the value is a quoted-string that specifies the group the Rendition belongs to. See Section 4.3.4.1.1. This attribute is REQUIRED.

LANGUAGE ๐Ÿ—ฃ๏ธ

the value is a quoted-string containing one of the standard Tags for Identifying Languages [RFC5646], which identifies the primary language used in the Rendition. This attribute is OPTIONAL.

ASSOC-LANGUAGE ๐Ÿ’ฌ

the value is a quoted-string containing a language tag [RFC5646] that identifies a language associated with the Rendition. An associated language is often used in a different role than the one in the LANGUAGE attribute (like written versus spoken, or a fallback dialect) ๐Ÿค“ This attribute is OPTIONAL.

the LANGUAGE and ASSOC-LANGUAGE attributes can be used together, for example, to link Norwegian Renditions that use different spoken and written languages ๐Ÿ‡ณ๐Ÿ‡ด

NAME ๐Ÿท๏ธ

the value is a quoted-string with a human-readable description of the Rendition. If the LANGUAGE attribute is present, this description SHOULD be in that language. This attribute is REQUIRED.

DEFAULT โญ

the value is an enumerated-string, and the valid strings are YES and NO. If the value is YES, the client SHOULD play this Rendition of the content when the user hasn't indicated a different choice. This attribute is OPTIONAL. If it's absent, the implicit value is NO.

AUTOSELECT ๐Ÿค–

the value is an enumerated-string, and the valid strings are YES and NO. This attribute is OPTIONAL. If it's absent, the implicit value is NO. If the value is YES, the client MAY choose to play this Rendition without an explicit user preference, because it matches the current playback environment, like the chosen system language ๐ŸŒ

if the AUTOSELECT attribute is present, its value MUST be YES if the DEFAULT attribute's value is YES ๐Ÿ’ฏ

FORCED ๐Ÿšจ

the value is an enumerated-string, and the valid strings are YES and NO. This attribute is OPTIONAL. If it's absent, the implicit value is NO. The FORCED attribute MUST NOT be present unless the TYPE is SUBTITLES ๐Ÿ“

  • a value of YES means the Rendition has content that's considered essential to play. When selecting a FORCED Rendition, a client SHOULD choose the one that best matches the current playback environment (like language) ๐ŸŽฏ
  • a value of NO means the Rendition has content that's meant to be played in response to an explicit user request ๐Ÿ™‹โ€โ™€๏ธ

INSTREAM-ID ๐Ÿ“ก

the value is a quoted-string that specifies a Rendition within the segments in the Media Playlist. This attribute is REQUIRED if the TYPE attribute is CLOSED-CAPTIONS. In that case it MUST have one of these values: "CC1", "CC2", "CC3", "CC4", or "SERVICEn", where n MUST be an integer between 1 and 63 (e.g., "SERVICE3" or "SERVICE42") ๐Ÿ’…

the values "CC1", "CC2", "CC3", and "CC4" identify a Line 21 Data Services channel [CEA608]. The "SERVICE" values identify a Digital Television Closed Captioning [CEA708] service block number ๐Ÿ“บ

for all other TYPE values, the INSTREAM-ID MUST NOT be specified ๐Ÿ™…

CHARACTERISTICS ๐Ÿง

the value is a quoted-string containing one or more Uniform Type Identifiers [UTI], separated by comma (,) characters. This attribute is OPTIONAL. Each UTI indicates an individual characteristic of the Rendition โœจ

a SUBTITLES Rendition MAY include these characteristics: "public.accessibility.transcribes-spoken-dialog", "public.accessibility.describes-music-and-sound", and "public.easy-to-read" (which means the subtitles have been edited for ease of reading) ๐Ÿ“–

an AUDIO Rendition MAY include this characteristic: "public.accessibility.describes-video" ๐ŸŽ™๏ธ

the CHARACTERISTICS attribute MAY include private UTIs too ๐Ÿ”

CHANNELS ๐Ÿ”Š

the value is a quoted-string that specifies an ordered, backslash-separated ("/") list of parameters. If the TYPE attribute is AUDIO, the first parameter is a count of audio channels, expressed as a decimal-integer. That count is the maximum number of independent, simultaneous audio channels present in any Media Segment in the Rendition. For example, an AC-3 5.1 Rendition would have a CHANNELS="6" attribute. No other CHANNELS parameters are currently defined ๐ŸŽถ

all audio EXT-X-MEDIA tags SHOULD have a CHANNELS attribute. If a Master Playlist has two Renditions encoded with the same codec but a different number of channels, the CHANNELS attribute is REQUIRED. Otherwise, it's OPTIONAL ๐ŸŒธ

4.3.4.1.1. Rendition Groups ๐ŸŒˆ

a set of one or more EXT-X-MEDIA tags with the same GROUP-ID value and the same TYPE value defines a Group of Renditions ๐Ÿงบ Each member of the Group MUST be an alternative Rendition of the same content. Otherwise, playback errors can occur ๐Ÿ˜ฌ

all EXT-X-MEDIA tags in a Playlist MUST meet these constraints ๐Ÿ‘‡

  • all EXT-X-MEDIA tags in the same Group MUST have different NAME attributes ๐Ÿท๏ธ
  • a Group MUST NOT have more than one member with a DEFAULT attribute of YES โ˜๏ธ
  • each EXT-X-MEDIA tag with an AUTOSELECT=YES attribute SHOULD have a combination of LANGUAGE [RFC5646], ASSOC-LANGUAGE, FORCED, and CHARACTERISTICS attributes that's distinct from the other AUTOSELECT=YES members of its Group ๐Ÿซง

a Playlist MAY contain multiple Groups of the same TYPE to provide multiple encodings of that media type. If it does, each Group of the same TYPE MUST have the same set of members, and each corresponding member MUST have identical attributes, except for the URI and CHANNELS attributes ๐Ÿงฉ

each member in a Group of Renditions MAY have a different sample format. For example, an English Rendition can be encoded with AC-3 5.1 while a Spanish Rendition is encoded with AAC stereo ๐ŸŽผ However, any EXT-X-STREAM-INF tag (Section 4.3.4.2) or EXT-X-I-FRAME-STREAM-INF tag (Section 4.3.4.3) that references such a Group MUST have a CODECS attribute that lists every sample format present in any Rendition in the Group. Otherwise, client playback failures can occur ๐Ÿ’€ In the example above, the CODECS attribute would include "ac-3,mp4a.40.2" ๐Ÿ’œ

4.3.4.2. EXT-X-STREAM-INF ๐Ÿ’–

okay so EXT-X-STREAM-INF is the tag that declares a Variant Stream ๐ŸŽ€ It's a bundle of Renditions that can be combined to play the presentation, and the attributes on the tag tell you all about that bundle โœจ

The URI line right after the tag points to a Media Playlist that carries one Rendition of the Variant Stream. The URI line is REQUIRED ๐Ÿซถ Clients that don't support multiple video Renditions SHOULD play this one.

Its format is:

#EXT-X-STREAM-INF:<attribute-list>
<URI>

These are the attributes you can use:

BANDWIDTH

The value is a decimal-integer of bits per second. It's the peak segment bit rate of the Variant Stream ๐Ÿ“ˆ

If all the Media Segments in a Variant Stream have already been created, the BANDWIDTH value MUST be the largest sum of peak segment bit rates that any playable combination of Renditions produces. (For a Variant Stream with a single Media Playlist, that's just the peak segment bit rate of that Media Playlist.) An inaccurate value can cause playback stalls or stop clients from playing the variant ๐Ÿ’€

If the Master Playlist is going to be available before all Media Segments in the presentation are encoded, the BANDWIDTH value SHOULD be the BANDWIDTH value of a representative period of similar content, encoded with the same settings.

Every EXT-X-STREAM-INF tag MUST include the BANDWIDTH attribute. No exceptions, bestie ๐Ÿ‘‘

AVERAGE-BANDWIDTH

The value is a decimal-integer of bits per second. It's the average segment bit rate of the Variant Stream ๐Ÿฆ‹

If all the Media Segments in a Variant Stream have already been created, the AVERAGE-BANDWIDTH value MUST be the largest sum of average segment bit rates that any playable combination of Renditions produces. (For a Variant Stream with a single Media Playlist, that's just the average segment bit rate of that Media Playlist.) An inaccurate value can cause playback stalls or stop clients from playing the variant ๐Ÿ˜ญ

If the Master Playlist is going to be available before all Media Segments in the presentation are encoded, the AVERAGE-BANDWIDTH value SHOULD be the AVERAGE-BANDWIDTH value of a representative period of similar content, encoded with the same settings.

The AVERAGE-BANDWIDTH attribute is OPTIONAL ๐ŸŒธ

CODECS

The value is a quoted-string with a comma-separated list of formats. Each format names a media sample type that shows up in one or more Renditions of the Variant Stream ๐ŸŽถ The valid format identifiers are the ones in the ISO Base Media File Format Name Space, defined by "The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types" [RFC6381].

For example, a stream with AAC low complexity (AAC-LC) audio and H.264 Main Profile Level 3.0 video would have a CODECS value of "mp4a.40.2,avc1.4d401e" ๐Ÿ“

Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute.

RESOLUTION

The value is a decimal-resolution that describes the optimal pixel resolution to display all the video in the Variant Stream ๐Ÿ“บ

The RESOLUTION attribute is OPTIONAL, but it's recommended if the Variant Stream includes video ๐Ÿ’…

FRAME-RATE

The value is a decimal-floating-point number that describes the maximum frame rate for all the video in the Variant Stream, rounded to three decimal places ๐ŸŽž๏ธ

The FRAME-RATE attribute is OPTIONAL, but it's recommended if the Variant Stream includes video. The FRAME-RATE attribute SHOULD be included if any video in a Variant Stream exceeds 30 frames per second. Main character energy ๐ŸŒˆ

HDCP-LEVEL

The value is an enumerated-string. The valid strings are TYPE-0 and NONE. This attribute is advisory ๐Ÿง A value of TYPE-0 means the Variant Stream could fail to play unless the output is protected by High-bandwidth Digital Content Protection (HDCP) Type 0 [HDCP] or equivalent. A value of NONE means the content doesn't require output copy protection.

Encrypted Variant Streams with different HDCP levels SHOULD use different media encryption keys ๐Ÿ”

The HDCP-LEVEL attribute is OPTIONAL. It SHOULD be present if any content in the Variant Stream will fail to play without HDCP. Clients without output copy protection SHOULD NOT load a Variant Stream with an HDCP-LEVEL attribute unless its value is NONE ๐Ÿ™ˆ

AUDIO

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 Master Playlist whose TYPE attribute is AUDIO. It indicates the set of audio Renditions that SHOULD be used when playing the presentation ๐ŸŽง See Section 4.3.4.2.1.

The AUDIO attribute is OPTIONAL.

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 Master Playlist whose TYPE attribute is VIDEO. It indicates the set of video Renditions that SHOULD be used when playing the presentation ๐ŸŽฅ See Section 4.3.4.2.1.

The VIDEO attribute is OPTIONAL.

SUBTITLES

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 Master Playlist whose TYPE attribute is SUBTITLES. It indicates the set of subtitle Renditions that can be used when playing the presentation ๐Ÿ’ฌ See Section 4.3.4.2.1.

The SUBTITLES attribute is OPTIONAL.

CLOSED-CAPTIONS

The value can be either a quoted-string or an enumerated-string with the value NONE. If 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 CLOSED-CAPTIONS. It indicates the set of closed-caption Renditions that can be used when playing the presentation ๐Ÿ“ See Section 4.3.4.2.1.

If the value is the enumerated-string NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE, which means there are no closed captions in any Variant Stream in the Master Playlist. Having closed captions in one Variant Stream but not another can trigger playback inconsistencies ๐Ÿ˜ตโ€๐Ÿ’ซ

The CLOSED-CAPTIONS attribute is OPTIONAL.

4.3.4.2.1. Alternative Renditions ๐ŸŒท

When an EXT-X-STREAM-INF tag contains an AUDIO, VIDEO, SUBTITLES, or CLOSED-CAPTIONS attribute, it means alternative Renditions of the content are available for playing that Variant Stream ๐Ÿ”€

When you're defining alternative Renditions, the following constraints MUST be met to prevent client playback errors ๐Ÿšซ

  • All playable combinations of Renditions associated with an EXT-X-STREAM-INF tag MUST have an aggregate bandwidth less than or equal to the BANDWIDTH attribute of that EXT-X-STREAM-INF tag.
  • If an EXT-X-STREAM-INF tag contains a RESOLUTION attribute and a VIDEO attribute, then every alternative video Rendition MUST have an optimal display resolution that matches the value of the RESOLUTION attribute.
  • Every alternative Rendition associated with an EXT-X-STREAM-INF tag MUST meet the constraints for a Variant Stream described in Section 6.2.4.

The URI attribute of the EXT-X-MEDIA tag is REQUIRED if the media type is SUBTITLES, but OPTIONAL if the media type is VIDEO or AUDIO. If the media type is VIDEO or AUDIO, a missing URI attribute means the media data for this Rendition is included in the Media Playlist of any EXT-X-STREAM-INF tag that references this EXT-X-MEDIA tag ๐Ÿซง If the media TYPE is AUDIO and the URI attribute is missing, clients MUST assume that the audio data for this Rendition is present in every video Rendition specified by the EXT-X-STREAM-INF tag.

The URI attribute of the EXT-X-MEDIA tag MUST NOT be included if the media type is CLOSED-CAPTIONS ๐Ÿšซโœจ

4.3.4.3. EXT-X-I-FRAME-STREAM-INF ๐Ÿงš

The EXT-X-I-FRAME-STREAM-INF tag identifies a Media Playlist file that contains the I-frames of a multimedia presentation ๐Ÿ–ผ๏ธ It stands alone, meaning it doesn't apply to a particular URI in the Master Playlist. Its format is:

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

All attributes defined for the EXT-X-STREAM-INF tag (Section 4.3.4.2) are also defined for the EXT-X-I-FRAME-STREAM-INF tag, except for the FRAME-RATE, AUDIO, SUBTITLES, and CLOSED-CAPTIONS attributes. On top of that, the following attribute is defined:

URI

The value is a quoted-string containing a URI that identifies the I-frame Media Playlist file. That Playlist file MUST contain an EXT-X-I-FRAMES-ONLY tag ๐ŸŽฏ

Every EXT-X-I-FRAME-STREAM-INF tag MUST include a BANDWIDTH attribute and a URI attribute.

The provisions in Section 4.3.4.2.1 also apply to EXT-X-I-FRAME-STREAM-INF tags with a VIDEO attribute.

A Master Playlist that specifies alternative VIDEO Renditions and I-frame Playlists SHOULD include an alternative I-frame VIDEO Rendition for each regular VIDEO Rendition, with the same NAME and LANGUAGE attributes ๐Ÿ‘ฏ

4.3.4.4. EXT-X-SESSION-DATA ๐Ÿ“ฆ

The EXT-X-SESSION-DATA tag lets you carry arbitrary session data in a Master Playlist ๐ŸŽ

Its format is:

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

The following attributes are defined:

DATA-ID

The value of DATA-ID is a quoted-string that identifies a particular data value. The DATA-ID SHOULD follow a reverse DNS naming convention, like "com.example.movie.title". There's no central registration authority, though, so Playlist authors SHOULD take care to choose a value that's unlikely to collide with others ๐Ÿคž This attribute is REQUIRED.

VALUE

VALUE is a quoted-string. It contains the data identified by DATA-ID. If the LANGUAGE is specified, VALUE SHOULD contain a human-readable string written in that language ๐Ÿ—ฃ๏ธ

URI

The value is a quoted-string containing a URI. The resource identified by the URI MUST be formatted as JSON [RFC7159]. Otherwise, clients may fail to interpret the resource ๐Ÿงพ

LANGUAGE

The value is a quoted-string containing a language tag [RFC5646] that identifies the language of the VALUE. This attribute is OPTIONAL ๐ŸŒ

Each EXT-X-SESSION-DATA tag MUST contain either a VALUE or URI attribute, but not both ๐Ÿ™…โ€โ™€๏ธ

A Playlist MAY contain multiple EXT-X-SESSION-DATA tags with the same DATA-ID attribute. A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute ๐Ÿ’œ

4.3.4.5. EXT-X-SESSION-KEY ๐Ÿ”‘

okay so the EXT-X-SESSION-KEY tag lets you put encryption keys from Media Playlists right in the Master Playlist ๐ŸŽ€ so the client can preload them โœจ without having to go read the Media Playlist(s) first. no extra trips, bestie ๐Ÿงš

Its format is:

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

every attribute defined for EXT-X-KEY (Section 4.3.2.4) is also defined for EXT-X-SESSION-KEY, except that the value of the METHOD attribute MUST NOT be NONE ๐Ÿ™…โ€โ™€๏ธ. and if you use an EXT-X-SESSION-KEY, the values of the METHOD, KEYFORMAT, and KEYFORMATVERSIONS attributes MUST match any EXT-X-KEY with the same URI value ๐Ÿ’œ. no mismatches, periodt ๐Ÿ’…

EXT-X-SESSION-KEY tags SHOULD be added if multiple Variant Streams or Renditions use the same encryption keys and formats ๐Ÿฆ‹. and an EXT-X-SESSION-KEY tag isn't tied to any particular Media Playlist ๐ŸŒธ

A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values. no duplicates, obviously ๐Ÿ™ˆ

The EXT-X-SESSION-KEY tag is optional.


4.3.5. Media or Master Playlist Tags ๐ŸŒˆ

the tags in this section can show up in either Master Playlists or Media Playlists. if one of these tags shows up in a Master Playlist, it SHOULD NOT appear in any Media Playlist referenced by that Master Playlist ๐Ÿซถ. a tag that shows up in both MUST have the same value; otherwise, clients SHOULD ignore the value in the Media Playlist(s) ๐Ÿ’€

these tags MUST NOT appear more than once in a Playlist. if a tag appears more than once, clients MUST fail to parse the Playlist ๐Ÿ˜ญ

4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS ๐Ÿงฉ

the EXT-X-INDEPENDENT-SEGMENTS tag tells you that all media samples in a Media Segment can be decoded without info from other segments. it applies to every Media Segment in the Playlist โœจ

Its format is:

#EXT-X-INDEPENDENT-SEGMENTS

if the EXT-X-INDEPENDENT-SEGMENTS tag shows up in a Master Playlist, it applies to every Media Segment in every Media Playlist in the Master Playlist ๐Ÿ‘‘

4.3.5.2. EXT-X-START โฏ๏ธ

the EXT-X-START tag is the server's preferred starting point for a Playlist ๐ŸŽฌ. by default, clients SHOULD start playback at this point when beginning a playback session. this tag is OPTIONAL.

Its format is:

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

these attributes are defined:

TIME-OFFSET

the value of TIME-OFFSET is a signed-decimal-floating-point number of seconds ๐Ÿ”ข. a positive number is a time offset from the beginning of the Playlist, and a negative number is a negative time offset from the end of the last Media Segment in the Playlist. this attribute is REQUIRED.

the absolute value of TIME-OFFSET SHOULD NOT be larger than the Playlist duration. if the absolute value of TIME-OFFSET goes past the duration of the Playlist, it means either the end of the Playlist (if positive) or the beginning of the Playlist (if negative) ๐Ÿซ 

if the Playlist does not contain the EXT-X-ENDLIST tag, the TIME-OFFSET SHOULD NOT be within three target durations of the end of the Playlist file ๐Ÿ™…โ€โ™€๏ธ

PRECISE

the value is an enumerated-string, and the valid strings are YES and NO ๐ŸŽฏ. if the value is YES, clients SHOULD start playback at the Media Segment containing the TIME-OFFSET, but SHOULD NOT render media samples in that segment whose presentation times are prior to the TIME-OFFSET. if the value is NO, clients SHOULD attempt to render every media sample in that segment. this attribute is OPTIONAL. if it's missing, its value should be treated as NO ๐Ÿค


5. Key Files ๐Ÿ”

5.1. Structure of Key Files

an EXT-X-KEY tag with a URI attribute identifies a Key file ๐Ÿ—๏ธ. a Key file contains a cipher key that can decrypt Media Segments in the Playlist.

[AES_128] encryption uses 16-octet keys. if the KEYFORMAT of an EXT-X-KEY tag is "identity", the Key file is a single packed array of 16 octets in binary format ๐Ÿ’…

5.2. IV for AES-128

[AES_128] REQUIRES the same 16-octet IV to be supplied when encrypting and decrypting. varying this IV increases the strength of the cipher ๐Ÿ’ช

an IV attribute on an EXT-X-KEY tag with a KEYFORMAT of "identity" specifies an IV that can be used when decrypting Media Segments encrypted with that Key file. IV values for AES-128 are 128-bit numbers ๐Ÿ”ข

an EXT-X-KEY tag with a KEYFORMAT of "identity" that does not have an IV attribute indicates that the Media Sequence Number is to be used as the IV when decrypting a Media Segment. you do that by putting its big-endian binary representation into a 16-octet (128-bit) buffer and padding (on the left) with zeros ๐Ÿง


6. Client/Server Responsibilities ๐Ÿ›ฐ๏ธ

6.1. Introduction

this section describes how the server generates the Playlist and Media Segments, and how the client should download them for playback ๐ŸŽž๏ธ

6.2. Server Responsibilities

6.2.1. General Server Responsibilities

the production of the source media is outside the scope of this document, which just presumes a source of continuous encoded media containing the presentation ๐ŸŽฅ

The server MUST divide the source media into individual Media Segments whose duration is less than or equal to a constant target duration. segments longer than the planned target duration can trigger playback stalls and other errors ๐Ÿ˜ฌ

The server SHOULD attempt to divide the source media at points that support effective decode of individual Media Segments, e.g., on packet and key frame boundaries ๐Ÿ”‘

The server MUST create a URI for every Media Segment that enables its clients to obtain the segment data. if a server supports partial loading of resources (e.g., via HTTP Range requests), it MAY specify segments as sub-ranges of larger resources using the EXT-X-BYTERANGE tag ๐Ÿฐ

any Media Segment that is specified in a Playlist loaded by a client MUST be available for immediate download, or playback errors can occur. once download starts, its transfer rate SHOULD NOT be constrained by the segment production process ๐Ÿš€

HTTP servers SHOULD transfer text files -- such as Playlists and WebVTT segments -- using the "gzip" Content-Encoding if the client indicates that it is prepared to accept it ๐Ÿ—œ๏ธ

The server must create a Media Playlist file (Section 4) that contains a URI for each Media Segment that the server wishes to make available, in the order in which they are to be played ๐Ÿ“œ

The value of the EXT-X-VERSION tag (Section 4.3.1.2) SHOULD NOT be greater than what is required for the tags and attributes in the Playlist (see Section 7) ๐Ÿ”ข

Changes to the Playlist file MUST be made atomically from the point of view of the clients, or playback errors MAY occur โš›๏ธ

The server MUST NOT change the Media Playlist file, except to:

  • Append lines to it (Section 6.2.1).
  • Remove Media Segment URIs from the Playlist in the order that they appear, along with any tags that apply only to those segments (Section 6.2.2).
  • Increment the value of the EXT-X-MEDIA-SEQUENCE or EXT-X-DISCONTINUITY-SEQUENCE tags (Section 6.2.2).
  • Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

a Media Playlist has further constraints on its updates if it contains an EXT-X-PLAYLIST-TYPE tag ๐Ÿง. an EXT-X-PLAYLIST-TYPE tag with a value of VOD means the Playlist file MUST NOT change. an EXT-X-PLAYLIST-TYPE tag with a value of EVENT means the server MUST NOT change or delete any part of the Playlist file, but it MAY append lines to it ๐Ÿ“ก

The value of the EXT-X-TARGETDURATION tag in the Media Playlist MUST NOT change. a typical target duration is 10 seconds โฑ๏ธ

Playlist changes other than those allowed here can trigger playback errors and inconsistent client behavior ๐Ÿ’€

each Media Segment in a Media Playlist has an integer Discontinuity Sequence Number ๐Ÿ”ข. the Discontinuity Sequence Number can be used in addition to the timestamps within the media to synchronize Media Segments across different Renditions ๐ŸŽถ

a segment's Discontinuity Sequence Number is the value of the EXT-X-DISCONTINUITY-SEQUENCE tag (or zero if there isn't one) plus the number of EXT-X-DISCONTINUITY tags in the Playlist preceding the URI line of the segment โž•

The server MAY associate an absolute date and time with a Media Segment by applying an EXT-X-PROGRAM-DATE-TIME tag to it. this defines an informative mapping of the (wall-clock) date and time specified by the tag to the first media timestamp in the segment, which may be used as a basis for seeking, for display, or for other purposes ๐Ÿ•ฐ๏ธ. if a server provides this mapping, it SHOULD apply an EXT-X-PROGRAM-DATE-TIME tag to every segment that has an EXT-X-DISCONTINUITY tag applied to it.

The Server MUST NOT add any EXT-X-PROGRAM-DATE-TIME tag to a Playlist that would cause the mapping between program date and Media Segment to become ambiguous ๐Ÿ™…โ€โ™€๏ธ

The server MUST NOT remove an EXT-X-DATERANGE tag from a Playlist if any date in the range maps to a Media Segment in the Playlist ๐Ÿ—“๏ธ

The server MUST NOT reuse the ID attribute value of an EXT-X-DATERANGE tag for any new Date Range in the same Playlist ๐Ÿ†”

Once the Following Range of a Date Range with an END-ON-NEXT=YES attribute is added to a Playlist, the Server MUST NOT subsequently add a Date Range with the same CLASS attribute whose START-DATE is between that of the END-ON-NEXT=YES range and its Following Range ๐Ÿšง

For Date Ranges with a PLANNED-DURATION attribute, the Server SHOULD signal the actual end of the range once it has been established. it can do so by adding another EXT-X-DATERANGE tag with the same ID attribute value and either a DURATION or an END-DATE attribute or, if the Date Range has an END-ON-NEXT=YES attribute, by adding a Following Range ๐Ÿ

if the Media Playlist contains the final Media Segment of the presentation, then the Playlist file MUST contain the EXT-X-ENDLIST tag. this lets clients minimize unproductive Playlist reloads ๐Ÿ›‘

if a Media Playlist does not contain the EXT-X-ENDLIST tag, the server MUST make a new version of the Playlist file available that contains at least one new Media Segment. it MUST be made available relative to the time that the previous version of the Playlist file was made available: no earlier than one-half the target duration after that time, and no later than 1.5 times the target duration after that time. this lets clients use the network efficiently ๐ŸŒŠ

if the server wishes to remove an entire presentation, it SHOULD provide a clear indication to clients that the Playlist file is no longer available (e.g., with an HTTP 404 or 410 response). It MUST ensure that all Media Segments in the Playlist file remain available to clients for at least the duration of the Playlist file at the time of removal, to prevent interruption of in-progress playback ๐Ÿซถ

6.2.2. Live Playlists

Okay so, the server MAY limit how long Media Segments stick around by pulling them out of the Playlist file (see Section 6.2.1) ๐Ÿ—‘๏ธ. If it's going to remove any, the Playlist file MUST contain an EXT-X-MEDIA-SEQUENCE tag. Its value MUST go up by 1 for every Media Segment that gets yeeted from the Playlist file, and it MUST NOT decrease or wrap. Clients can malfunction if each Media Segment doesn't have a consistent, unique Media Sequence Number ๐Ÿ’€.

Media Segments MUST be removed from the Playlist file in the order that they appear in the Playlist, or client playback can malfunction. Bestie, keep the order consistent ๐ŸŽ€.

The server MUST NOT remove a Media Segment from a Playlist file without an EXT-X-ENDLIST tag if that would leave a Playlist whose duration is less than three times the target duration. Doing so can trigger playback stalls ๐Ÿ˜ญ.

When the server removes a Media Segment URI from the Playlist, the corresponding Media Segment MUST stay available to clients for a period of time equal to the duration of the segment plus the duration of the longest Playlist file the server distributed that contains that segment. Removing it any earlier can interrupt playback that's already in progress ๐Ÿฆ‹.

If the server wants to remove segments from a Media Playlist that contains an EXT-X-DISCONTINUITY tag, the Media Playlist MUST contain an EXT-X-DISCONTINUITY-SEQUENCE tag. Without it, it can be impossible for a client to locate corresponding segments between Renditions ๐Ÿงš.

If the server removes an EXT-X-DISCONTINUITY tag from the Media Playlist, it MUST increment the value of the EXT-X-DISCONTINUITY-SEQUENCE tag, so the Discontinuity Sequence Numbers of the segments still in the Media Playlist stay unchanged โœจ. The value of the EXT-X-DISCONTINUITY-SEQUENCE tag MUST NOT decrease or wrap. Clients can malfunction if each Media Segment doesn't have a consistent Discontinuity Sequence Number ๐Ÿ’….

If a server plans to remove a Media Segment after it's been delivered to clients over HTTP, it SHOULD make sure the HTTP response contains an Expires header that reflects the planned time-to-live ๐ŸŒธ.

A Live Playlist MUST NOT contain the EXT-X-PLAYLIST-TYPE tag, because no value of that tag allows Media Segments to be removed. Not me putting a tag that contradicts the whole point of a live stream ๐Ÿ™ˆ.


6.2.3. Encrypting Media Segments

Media Segments MAY be encrypted ๐Ÿ”. Every encrypted Media Segment MUST have an EXT-X-KEY tag (Section 4.3.2.4) applied to it, with a URI the client can use to grab a Key file (Section 5) that contains the decryption key ๐Ÿ—๏ธ.

A Media Segment can only be encrypted with one encryption METHOD, using one encryption key and one IV. However, a server MAY offer multiple ways to retrieve that key by providing multiple EXT-X-KEY tags, each with a different KEYFORMAT attribute value ๐ŸŒˆ.

The server MAY set the HTTP Expires header in the key response to indicate how long the key can be cached ๐Ÿง.

Any unencrypted Media Segment in a Playlist that comes after an encrypted Media Segment MUST have an EXT-X-KEY tag applied to it with a METHOD attribute of NONE. Otherwise, the client will misinterpret those segments as encrypted ๐Ÿ™ƒ.

If the encryption METHOD is AES-128 and the Playlist does not contain the EXT-X-I-FRAMES-ONLY tag, AES encryption as described in Section 4.3.2.4 SHALL be applied to individual Media Segments ๐Ÿ’–.

If the encryption METHOD is AES-128 and the Playlist contains an EXT-X-I-FRAMES-ONLY tag, the entire resource MUST be encrypted using AES-128 CBC with PKCS7 padding [RFC5652]. Encryption MAY be restarted on 16-byte block boundaries, unless the first block contains an I-frame. The IV used for encryption MUST be either the Media Sequence Number of the Media Segment or the value of the IV attribute of the EXT-X-KEY tag, as described in Section 5.2. These constraints let a client load and decrypt individual I-frames that are specified as sub-ranges of regular encrypted Media Segments, along with their Media Initialization Sections ๐ŸŽฌโœจ.

If the encryption METHOD is SAMPLE-AES, media samples MAY be encrypted before they're encapsulated in a Media Segment ๐Ÿฆ‹.

The server MUST NOT remove an EXT-X-KEY tag from the Playlist file if it applies to any Media Segment in the Playlist file, or clients who load that Playlist later won't be able to decrypt those Media Segments. Keep that key tag, babe ๐Ÿ”‘๐Ÿ˜ญ.


6.2.4. Providing Variant Streams

A server MAY offer multiple Media Playlist files to provide different encodings of the same presentation ๐ŸŽž๏ธ. If it does, it SHOULD provide a Master Playlist file that lists each Variant Stream, so clients can switch between encodings dynamically ๐Ÿ”€.

Master Playlists describe regular Variant Streams with EXT-X-STREAM-INF tags, and I-frame Variant Streams with EXT-X-I-FRAME-STREAM-INF tags ๐Ÿ‘‘.

If an EXT-X-STREAM-INF tag or EXT-X-I-FRAME-STREAM-INF tag contains the CODECS attribute, the attribute value MUST include every media format [RFC6381] present in any Media Segment in any of the Renditions specified by the Variant Stream. List every codec, no skipping ๐ŸŽ€.

The server MUST meet the following constraints when producing Variant Streams, so clients can switch between them seamlessly ๐Ÿซถ:

  • Each Variant Stream MUST present the same content.
  • Matching content in Variant Streams MUST have matching timestamps. This lets clients synchronize the media โฑ๏ธ.
  • Matching content in Variant Streams MUST have matching Discontinuity Sequence Numbers (see Section 4.3.3.3).
  • Each Media Playlist in each Variant Stream MUST have the same target duration. The only exceptions are SUBTITLES Renditions and Media Playlists containing an EXT-X-I-FRAMES-ONLY tag, which MAY have different target durations if they have an EXT-X-PLAYLIST-TYPE of VOD.
  • Content that appears in a Media Playlist of one Variant Stream but not in another MUST appear either at the beginning or at the end of the Media Playlist file, and MUST NOT be longer than the target duration.
  • If any Media Playlists have an EXT-X-PLAYLIST-TYPE tag, all Media Playlists MUST have an EXT-X-PLAYLIST-TYPE tag with the same value.
  • If the Playlist contains an EXT-X-PLAYLIST-TYPE tag with the value of VOD, the first segment of every Media Playlist in every Variant Stream MUST start at the same media timestamp.
  • If any Media Playlist in a Master Playlist contains an EXT-X-PROGRAM-DATE-TIME tag, then all Media Playlists in that Master Playlist MUST contain EXT-X-PROGRAM-DATE-TIME tags with consistent mappings of date and time to media timestamps ๐Ÿ—“๏ธ.
  • Each Variant Stream MUST contain the same set of Date Ranges, each one identified by an EXT-X-DATERANGE tag(s) with the same ID attribute value and containing the same set of attribute/value pairs ๐Ÿ“….

In addition, for the broadest compatibility, Variant Streams SHOULD contain the same encoded audio bitstream. This lets clients switch between Variant Streams without audible glitching ๐ŸŽงโœจ.

The rules for Variant Streams also apply to alternative Renditions (see Section 4.3.4.2.1). Same rules, same vibes ๐Ÿ’œ.


6.3. Client Responsibilities

6.3.1. General Client Responsibilities

How the client gets the URI to the Playlist file is outside the scope of this document. It's presumed to have done so already ๐Ÿ™Œ.

The client obtains the Playlist file from the URI. If the Playlist file it gets is a Master Playlist, the client can select a Variant Stream to load from the Master Playlist ๐Ÿงญ.

Clients MUST ensure that loaded Playlists comply with Section 4, and that the EXT-X-VERSION tag, if present, specifies a protocol version the client supports. If either check fails, the client MUST NOT attempt to use the Playlist, or unintended behavior could occur ๐Ÿšซ.

If any URI element in a Playlist contains a URI scheme that the client cannot handle, the client MUST stop playback. All clients MUST support HTTP schemes ๐ŸŒ.

To support forward compatibility, when parsing Playlists, clients MUST:

  • ignore any unrecognized tags.
  • ignore any attribute/value pair with an unrecognized AttributeName.
  • ignore any tag containing an attribute/value pair of type enumerated-string whose AttributeName is recognized but whose AttributeValue is not recognized, unless the definition of the attribute says otherwise ๐Ÿงธ.

Algorithms the client uses to switch between Variant Streams are beyond the scope of this document ๐Ÿฆ‹.


6.3.2. Loading the Media Playlist File

Every time a Media Playlist is loaded or reloaded from a Playlist URI, the client MUST determine the next Media Segment to load, as described in Section 6.3.5, if it intends to play the presentation normally (i.e., in Playlist order at the nominal playback rate) โ–ถ๏ธ.

If the Media Playlist contains the EXT-X-MEDIA-SEQUENCE tag, the client SHOULD assume that each Media Segment in it will become unavailable at the time the Playlist file was loaded plus the duration of the Playlist file โณ.

A client MAY use the segment Media Sequence Number to track the location of a Media Segment within a Playlist when the Playlist is reloaded ๐Ÿ“.

A client MUST NOT assume that segments with the same Media Sequence Number in different Variant Streams or Renditions have the same position in the presentation. Playlists MAY have independent Media Sequence Numbers. Instead, a client MUST use the relative position of each segment on the Playlist timeline, plus its Discontinuity Sequence Number, to locate corresponding segments ๐Ÿ”๐Ÿ’….

A client MUST load the Media Playlist file of every Rendition selected for playback, in order to locate the media specific to that Rendition. But, to prevent unnecessary load on the server, it SHOULD NOT load the Playlist file of any other Rendition ๐Ÿ™.

For some Variant Streams, it's possible to select Renditions that don't include the Rendition specified by the EXT-X-STREAM-INF tag. As noted above, the client SHOULD NOT load that Rendition in those cases ๐Ÿซ .

6.3.3. Playing the Media Playlist File ๐ŸŽฌ

okay so when playback starts, the client SHALL choose which Media Segment to play first from the Media Playlist. โœจ If the EXT-X-ENDLIST tag is not present and the client intends to play the media normally, the client SHOULD NOT choose a segment that starts less than three target durations from the end of the Playlist file. Doing so can trigger playback stalls. ๐Ÿ˜ญ

Normal playback can be achieved by playing the Media Segments in the order that they appear in the Playlist. ๐Ÿ’– The client MAY present the available media in any way it wishes, including normal playback, random access, and trick modes. ๐Ÿฆ‹

The encoding parameters for samples in a Media Segment and across multiple Media Segments in a Media Playlist SHOULD remain consistent. ๐ŸŒธ However, clients SHOULD deal with encoding changes as they are encountered, for example, by scaling video content to accommodate a resolution change. ๐Ÿ”ฅ If the Variant Stream includes a RESOLUTION attribute, clients SHOULD display all video within a rectangle with the same proportions as that resolution. ๐Ÿ’…

Clients SHOULD be prepared to handle multiple tracks of a particular type (e.g., audio or video). ๐Ÿงš A client with no other preference SHOULD choose the track with the lowest numerical track identifier that it can play. โœจ

Clients SHOULD ignore private streams inside Transport Streams that they do not recognize. ๐Ÿ™ˆ Private streams can be used to support different devices with the same stream, although stream authors SHOULD be sensitive to the additional network load that this imposes. ๐Ÿ’€

The client MUST be prepared to reset its parser(s) and decoder(s) before playing a Media Segment that has an EXT-X-DISCONTINUITY tag applied to it; otherwise, playback errors can occur. ๐Ÿšจ

The client SHOULD attempt to load Media Segments in advance of when they will be required for uninterrupted playback to compensate for temporary variations in latency and throughput. ๐Ÿซถ

The client MAY use the value of the EXT-X-PROGRAM-DATE-TIME tag to display the program origination time to the user. ๐Ÿ•ฐ๏ธ If the value includes time zone information, the client SHALL take it into account; if it does not, the client MAY assume the time to be local. ๐ŸŒ

Note that dates in Playlists can refer to when the content was produced (or to other times), which have no relation to the time of playback. ๐Ÿ™ƒ

If the first EXT-X-PROGRAM-DATE-TIME tag in a Playlist appears after one or more Media Segment URIs, the client SHOULD extrapolate backward from that tag (using EXTINF durations and/or media timestamps) to associate dates with those segments. โช To associate a date with any other Media Segment that does not have an EXT-X-PROGRAM-DATE-TIME tag applied to it directly, the client SHOULD extrapolate forward from the last EXT-X-PROGRAM-DATE-TIME tag appearing before that segment in the Playlist. โฉ


6.3.4. Reloading the Media Playlist File ๐Ÿ”„

The client MUST periodically reload a Media Playlist file to learn what media is currently available, unless it contains an EXT-X-PLAYLIST-TYPE tag with a value of VOD, or a value of EVENT and the EXT-X-ENDLIST tag is also present. ๐Ÿ“ก

However, the client MUST NOT attempt to reload the Playlist file more frequently than specified by this section, in order to limit the collective load on the server. ๐Ÿ™ bestie, the server needs a break too ๐Ÿ˜ญ

When a client loads a Playlist file for the first time or reloads a Playlist file and finds that it has changed since the last time it was loaded, the client MUST wait for at least the target duration before attempting to reload the Playlist file again, measured from the last time the client began loading the Playlist file. โฑ๏ธ

If the client reloads a Playlist file and finds that it has not changed, then it MUST wait for a period of one-half the target duration before retrying. ๐Ÿฅบ

After reloading a Media Playlist, the client SHOULD verify that each Media Segment in it has the same URI (and byte range, if specified) as the Media Segment with the same Media Sequence Number in the previous Media Playlist. ๐Ÿ” It SHOULD halt playback if it does not, as this normally indicates a server error. ๐Ÿ›‘

In order to reduce server load, the client SHOULD NOT reload the Playlist files of Variant Streams or alternate Renditions that are not currently being played. ๐Ÿ’ค If it decides to switch playback to a different Variant Stream, it SHOULD stop reloading the Playlist of the old Variant Stream and begin loading the Playlist of the new Variant Stream. ๐Ÿฆ‹ It can use the EXTINF durations and the constraints in Section 6.2.4 to determine the approximate location of corresponding media. ๐Ÿ“ Once media from the new Variant Stream has been loaded, the timestamps in the Media Segments can be used to synchronize the old and new timelines precisely. โฐโœจ

A client MUST NOT attempt to use the Media Sequence Number to synchronize between streams (see Section 6.3.2). ๐Ÿšซ that number is not the sync tool, sis ๐Ÿ’…


6.3.5. Determining the Next Segment to Load ๐Ÿ“ฅ

The client MUST examine the Media Playlist file every time it is loaded or reloaded to determine the next Media Segment to load, as the set of available media MAY have changed. ๐Ÿ‘€ always double-check the list, it's giving detective energy ๐Ÿ•ต๏ธโ€โ™€๏ธ

The first segment to load is generally the segment that the client has chosen to play first (see Section 6.3.3). ๐ŸŽ€

In order to play the presentation normally, the next Media Segment to load is the one with the lowest Media Sequence Number that is greater than the Media Sequence Number of the last Media Segment loaded. ๐Ÿ”ข next in line, no skipping, periodt ๐Ÿ’–


6.3.6. Decrypting Encrypted Media Segments ๐Ÿ”

If a Media Playlist file contains an EXT-X-KEY tag that specifies a Key file URI, the client can obtain that Key file and use the key inside it to decrypt all Media Segments to which that EXT-X-KEY tag applies. ๐Ÿ—๏ธ

A client MUST ignore any EXT-X-KEY tag with an unsupported or unrecognized KEYFORMAT attribute, to allow for cross-device addressability. ๐ŸŒˆ If the Playlist contains a Media Segment to which only EXT-X-KEY tags with unrecognized or unsupported KEYFORMAT attributes are applied, playback SHOULD fail. ๐Ÿ’”

A client MUST NOT attempt to decrypt any segments whose EXT-X-KEY tag has a METHOD attribute that it does not recognize. ๐Ÿšซ๐Ÿ”“

If the encryption METHOD is AES-128, AES-128 CBC decryption SHALL be applied to individual Media Segments, whose encryption format is described in Section 4.3.2.4. ๐Ÿ”‘

If the encryption METHOD is AES-128 and the Media Segment is part of an I-frame Playlist (Section 4.3.3.6) and it has an EXT-X-BYTERANGE tag applied to it, special care needs to be taken in loading and decrypting the segment, because the resource identified by the URI is encrypted in 16-byte blocks from the start of the resource. ๐Ÿงฉ this one is a little delicate, so pay attention ๐Ÿ‘‘

The decrypted I-frame can be recovered by first widening its byte range, as specified by the EXT-X-BYTERANGE tag, so that it starts and ends on 16-byte boundaries from the start of the resource.

Next, the byte range is widened further to include a 16-byte block at the beginning of the range. ๐Ÿ“ This 16-byte block allows the correct IV for the following block to be calculated. ๐Ÿงฎ

The widened byte range can then be loaded and decrypted with AES-128 CBC using an arbitrary IV. ๐Ÿช„ The number of bytes added to the beginning and the end of the original byte range are discarded from the decrypted bytes; what remains is the decrypted I-frame. โœ‚๏ธ๐Ÿ–ผ๏ธ

If the encryption METHOD is SAMPLE-AES, AES-128 decryption SHALL be applied to encrypted media samples within the Media Segment. ๐ŸŽž๏ธ

An EXT-X-KEY tag with a METHOD of NONE indicates that the Media Segments it applies to are not encrypted. ๐ŸŒท no lock, no key, all vibes ๐Ÿซง


7. Protocol Version Compatibility ๐ŸŽ€

Protocol compatibility is specified by the EXT-X-VERSION tag. ๐Ÿท๏ธ A Playlist that contains tags or attributes that are not compatible with protocol version 1 MUST include an EXT-X-VERSION tag. ๐Ÿ“Œ

A client MUST NOT attempt playback if it does not support the protocol version specified by the EXT-X-VERSION tag, or unintended behavior could occur. ๐Ÿ’€ not worth the chaos, bestie

A Media Playlist MUST indicate an EXT-X-VERSION of 2 or higher if it contains:

  • The IV attribute of the EXT-X-KEY tag.

A Media Playlist MUST indicate an EXT-X-VERSION of 3 or higher if it contains:

  • Floating-point EXTINF duration values.

A Media Playlist MUST indicate an EXT-X-VERSION of 4 or higher if it contains:

  • The EXT-X-BYTERANGE tag.
  • The EXT-X-I-FRAMES-ONLY tag.

A Media Playlist MUST indicate an EXT-X-VERSION of 5 or higher if it contains:

  • The KEYFORMAT and KEYFORMATVERSIONS attributes of the EXT-X-KEY tag.
  • The EXT-X-MAP tag.

A Media Playlist MUST indicate an EXT-X-VERSION of 6 or higher if it contains:

  • The EXT-X-MAP tag in a Media Playlist that does not contain EXT-X-I-FRAMES-ONLY.

A Master Playlist MUST indicate an EXT-X-VERSION of 7 or higher if it contains:

  • "SERVICE" values for the INSTREAM-ID attribute of the EXT-X-MEDIA tag.

The EXT-X-MEDIA tag and the AUDIO, VIDEO, and SUBTITLES attributes of the EXT-X-STREAM-INF tag are backward compatible to protocol version 1, but playback on older clients may not be desirable. ๐Ÿ•ฐ๏ธ A server MAY consider indicating an EXT-X-VERSION of 4 or higher in the Master Playlist but is not required to do so. ๐Ÿคทโ€โ™€๏ธ

The PROGRAM-ID attribute of the EXT-X-STREAM-INF and the EXT-X-I-FRAME-STREAM-INF tags was removed in protocol version 6. ๐Ÿ‘‹

The EXT-X-ALLOW-CACHE tag was removed in protocol version 7. ๐Ÿ‘‹โœจ


8. Playlist Examples ๐Ÿ“

8.1. Simple Media Playlist ๐ŸŽต

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXTINF:9.009,
http://media.example.com/first.ts
#EXTINF:9.009,
http://media.example.com/second.ts
#EXTINF:3.003,
http://media.example.com/third.ts
#EXT-X-ENDLIST

8.2. Live Media Playlist Using HTTPS ๐Ÿ“ก

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:2680

#EXTINF:7.975,
https://priv.example.com/fileSequence2680.ts
#EXTINF:7.941,
https://priv.example.com/fileSequence2681.ts
#EXTINF:7.975,
https://priv.example.com/fileSequence2682.ts

8.3. Playlist with Encrypted Media Segments ๐Ÿ”

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:7794
#EXT-X-TARGETDURATION:15

#EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=52"

#EXTINF:2.833,
http://media.example.com/fileSequence52-A.ts
#EXTINF:15.0,
http://media.example.com/fileSequence52-B.ts
#EXTINF:13.333,
http://media.example.com/fileSequence52-C.ts

#EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=53"

#EXTINF:15.0,
http://media.example.com/fileSequence53-A.ts

8.4. Master Playlist ๐Ÿ‘‘

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=1280000,AVERAGE-BANDWIDTH=1000000
http://example.com/low.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2560000,AVERAGE-BANDWIDTH=2000000
http://example.com/mid.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=7680000,AVERAGE-BANDWIDTH=6000000
http://example.com/hi.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5"
http://example.com/audio-only.m3u8

8.5. Master Playlist with I-Frames ๐ŸŒˆ

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=1280000
low/audio-video.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=86000,URI="low/iframe.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=2560000
mid/audio-video.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=150000,URI="mid/iframe.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=7680000
hi/audio-video.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=550000,URI="hi/iframe.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5"
audio-only.m3u8

8.6. Master Playlist with Alternative Audio

okay bestie, this one is all about switching the audio while the video stays put ๐ŸŽงโœจ the CODECS attributes got condensed so it fits on screen, and a \ at the end of a line just means "the tag keeps going on the next line, and ignore the whitespace" ๐Ÿ’…

#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="English", \
   DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en", \
   URI="main/english-audio.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="Deutsch", \
   DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="de", \
   URI="main/german-audio.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="Commentary", \
   DEFAULT=NO,AUTOSELECT=NO,LANGUAGE="en", \
   URI="commentary/audio-only.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="...",AUDIO="aac"
low/video-only.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2560000,CODECS="...",AUDIO="aac"
mid/video-only.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=7680000,CODECS="...",AUDIO="aac"
hi/video-only.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5",AUDIO="aac"
main/english-audio.m3u8

8.7. Master Playlist with Alternative Video

this example is giving "three video options, pick your vibe" ๐ŸŽฅ๐ŸŒˆ there are three video Renditions (Main, Centerfield, and Dugout) and three Variant Streams (low, mid, and high) ๐Ÿฆ‹ ngl, a client that doesn't understand the EXT-X-MEDIA tag or the VIDEO attribute of EXT-X-STREAM-INF would only be able to play the "Main" video Rendition ๐Ÿ˜ญ

since the EXT-X-STREAM-INF tag has no AUDIO attribute here, every video Rendition has to contain the audio too ๐ŸŽ€ again the CODECS attributes are condensed, and \ means "keep going on the next line" ๐Ÿ’–

#EXTM3U
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Main", \
   DEFAULT=YES,URI="low/main/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Centerfield", \
   DEFAULT=NO,URI="low/centerfield/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Dugout", \
   DEFAULT=NO,URI="low/dugout/audio-video.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="...",VIDEO="low"
low/main/audio-video.m3u8

#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Main", \
   DEFAULT=YES,URI="mid/main/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Centerfield", \
   DEFAULT=NO,URI="mid/centerfield/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Dugout", \
   DEFAULT=NO,URI="mid/dugout/audio-video.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=2560000,CODECS="...",VIDEO="mid"
mid/main/audio-video.m3u8

#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Main", \
   DEFAULT=YES,URI="hi/main/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Centerfield", \
   DEFAULT=NO,URI="hi/centerfield/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Dugout", \
   DEFAULT=NO,URI="hi/dugout/audio-video.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=7680000,CODECS="...",VIDEO="hi"
hi/main/audio-video.m3u8

8.8. Session Data in a Master Playlist

in this one we only look at EXT-X-SESSION-DATA ๐Ÿ“๐Ÿ“ it's basically the playlist's little notebook of extra info, with one entry for a lyrics file and two entries for a title in English and Spanish ๐ŸŒธ

#EXT-X-SESSION-DATA:DATA-ID="com.example.lyrics",URI="lyrics.json"

#EXT-X-SESSION-DATA:DATA-ID="com.example.title",LANGUAGE="en", \
        VALUE="This is an example"
#EXT-X-SESSION-DATA:DATA-ID="com.example.title",LANGUAGE="es", \
        VALUE="Este es un ejemplo"

8.9. CHARACTERISTICS Attribute Containing Multiple Characteristics

some characteristics are valid together, like best friends who only work as a duo ๐Ÿ‘ฏโ€โ™€๏ธ๐Ÿ’œ here's how that looks in the CHARACTERISTICS attribute:

CHARACTERISTICS=
"public.accessibility.transcribes-spoken-dialog,public.easy-to-read"

8.10. EXT-X-DATERANGE Carrying SCTE-35 Tags

okay this one is a little plot twist ๐ŸŽฌ๐Ÿ˜ฑ two EXT-X-DATERANGE tags describe ONE Date Range. first there's an SCTE-35 "out" splice_insert() command, then it gets updated with an SCTE-35 "in" splice_insert() command ๐Ÿฆ‹โœจ the ... lines just mean "more stuff goes here" ๐Ÿ’…

#EXTM3U
...
#EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2014-03-05T11:
15:00Z",PLANNED-DURATION=59.993,SCTE35-OUT=0xFC002F0000000000FF0
00014056FFFFFF000E011622DCAFF000052636200000000000A0008029896F50
000008700000000

... Media Segment declarations for 60s worth of media

#EXT-X-DATERANGE:ID="splice-6FFFFFF0",DURATION=59.993,SCTE35-IN=
0xFC002A0000000000FF00000F056FFFFFF000401162802E6100000000000A00
08029896F50000008700000000
...

9. IANA Considerations โœจ

okay so IANA registered a media type for this format ๐Ÿ“‚๐Ÿ’– here are all the details, bestie:

Type name: application

Subtype name: vnd.apple.mpegurl

Required parameters: none

Optional parameters: none

Encoding considerations: encoded as UTF-8, which is 8-bit text.  This
media type may require encoding on transports not capable of handling
8-bit text.  See Section 4 for more information.

Security considerations: See Section 10.

Compression: this media type does not employ compression.

Interoperability considerations: There are no byte-ordering issues,
since files are 8-bit text.  Applications could encounter
unrecognized tags, which SHOULD be ignored.

Published specification: see Section 4.

Applications that use this media type: Multimedia applications such
as the iPhone media player in iOS 3.0 and later and QuickTime Player
in Mac OS X version 10.6 and later.

Fragment identifier considerations: no Fragment Identifiers are
defined for this media type.

Additional information:

   Deprecated alias names for this type: none
   Magic number(s): #EXTM3U
   File extension(s): .m3u8, .m3u (see Section 4)
   Macintosh file type code(s): none

Person & email address to contact for further information: David
Singer, singer@apple.com.

Intended usage: LIMITED USE

Restrictions on usage: none

Author: Roger Pantos

Change Controller: David Singer

the big takeaway: unrecognized tags are supposed to be ignored, and the key word there is SHOULD ๐Ÿซถ (so clients are recommended to skip them, not forced).

10. Security Considerations ๐Ÿ”’

okay this section is SERIOUS but also kind of iconic ๐Ÿ˜ค๐Ÿ”ฅ I'm keeping every single point because security is not the place to cut corners, bestie ๐Ÿ’€

Since the protocol mostly runs on HTTP, pretty much all the same security stuff applies ๐ŸŒ go check Section 15 of HTTP [RFC7230] for the full tea.

Media file parsers get hit with "fuzzing" attacks all the time ๐Ÿ™ˆ implementors SHOULD pay particular attention to any code parsing data from a server, and make sure every possible input is handled correctly ๐Ÿงš

Playlist files contain URIs, and clients use those to make network requests to arbitrary entities ๐Ÿ‘€ clients SHOULD range-check responses to prevent buffer overflows ๐Ÿšจ also see the Security Considerations section of "Uniform Resource Identifier (URI): Generic Syntax" [RFC3986].

apart from URL resolution, this format does not use any form of active content. no sneaky scripts here ๐Ÿซก

Clients SHOULD limit each playback session to a reasonable number of concurrent downloads (e.g., four) so they don't end up contributing to denial-of-service attacks ๐Ÿ›ก๏ธ๐Ÿ’œ

HTTP requests often carry session state ("cookies"), and those can hold private user data ๐Ÿช implementations MUST follow the cookie restriction and expiry rules in "HTTP State Management Mechanism" [RFC6265] to protect themselves from attack ๐Ÿ’… also check the Security Considerations section of that document, plus "Use of HTTP State Management" [RFC2964].

Encryption keys are specified by URI, and their delivery SHOULD be secured by something like HTTP Over TLS [RFC2818] (formerly SSL), together with a secure realm or a session token ๐Ÿ”โœจ no keys floating around unprotected, periodt!

11. References ๐Ÿ“š

bestie, this is where all the sources live ๐ŸŒธ (more coming in the next part!)

11.1. Normative References โœจ

Okay bestie, this is the reading list you need before the spec makes full sense ๐Ÿ“š๐Ÿ’– Every one of these is a real dependency, so here they are with all their details.

[AC_3] Advanced Television Systems Committee, "Digital Audio Compression (AC-3) (E-AC-3) Standard", ATSC Standard A/52:2010, November 2010, <http://atsc.org/wp-content/uploads/2015/03/A52-201212-17.pdf>.

[AES_128] National Institute of Standards and Technology, "Advanced Encryption Standard (AES)", FIPS PUB 197, DOI 10.6028/NIST.FIPS.197, November 2001, <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf>. ๐Ÿ”

[CEA608] Consumer Electronics Association, "ANSI/CEA 608-E: Line 21 Data Services", April 2008. ๐Ÿ“บ

[CEA708] Consumer Technology Association, "Digital Television (DTV) Closed Captioning", ANSI/CTA Standard CEA-708-E, August 2013, <https://standards.cta.tech/kwspub/published_docs/ANSI-CTA-708-E-Preview.pdf>. ๐Ÿ’ฌ

[COMMON_ENC] International Organization for Standardization, "Information technology -- MPEG systems technologies -- Part 7: Common encryption in ISO base media file format files", ISO/IEC 23001-7:2016, February 2016, <http://www.iso.org/iso/catalogue_detail.htm?csnumber=68042>. ๐Ÿงฉ

[H_264] International Telecommunications Union, "Advanced video coding for generic audiovisual services", January 2012, <http://www.itu.int/rec/T-REC-H.264>. ๐ŸŽฌ

[HDCP] Digital Content Protection LLC, "High-bandwidth Digital Content Protection System - Mapping HDCP to HDMI", February 2013, <http://www.digital-cp.com/sites/default/files/specifications/HDCP%20on%20HDMI%20Specification%20Rev2_2_Final1.pdf>. ๐Ÿ›ก๏ธ

[ISO_13818] International Organization for Standardization, "Generic coding of moving pictures and associated audio information", ISO/IEC International Standard 13818, October 2007, <http://www.iso.org/iso/catalogue_detail?csnumber=44169>. ๐ŸŽž๏ธ

[ISO_13818_3] International Organization for Standardization, "ISO/IEC International Standard 13818-3:1998; Generic coding of moving pictures and associated audio information - Part 3: Audio", April 1998, <http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26797>. ๐ŸŽง

[ISO_13818_7] International Organization for Standardization, "Generic coding of moving pictures and associated audio information - Part 7: Advanced Audio Coding (AAC)", ISO/IEC International Standard 13818-3:2006, January 2006, <http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=43345>. ๐ŸŽถ

[ISO_14496] International Organization for Standardization, "Information technology -- Coding of audio-visual objects -- Part 3: Audio", ISO/IEC 14496-3:2009, 2009, <http://www.iso.org/iso/catalogue_detail?csnumber=53943>. ๐Ÿ”Š

[ISO_8601] International Organization for Standardization, "Data elements and interchange formats -- Information interchange -- Representation of dates and times", ISO/IEC International Standard 8601:2004, December 2004, <http://www.iso.org/iso/catalogue_detail?csnumber=40874>. ๐Ÿ—“๏ธ

[ISOBMFF] International Organization for Standardization, "Information technology -- Coding of audio-visual objects -- Part 12: ISO base media file format", ISO/IEC 14496-12:2015, December 2015, <http://www.iso.org/iso/catalogue_detail.htm?csnumber=68960>. ๐Ÿ“ฆ

[RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996, <https://www.rfc-editor.org/info/rfc2046>. ๐Ÿ’Œ

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>. ๐Ÿ”‘

[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, DOI 10.17487/RFC2818, May 2000, <https://www.rfc-editor.org/info/rfc2818>. ๐Ÿ”’

[RFC2964] Moore, K. and N. Freed, "Use of HTTP State Management", BCP 44, RFC 2964, DOI 10.17487/RFC2964, October 2000, <https://www.rfc-editor.org/info/rfc2964>. ๐Ÿช

[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2003, <https://www.rfc-editor.org/info/rfc3629>. ๐Ÿ”ค

[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005, <https://www.rfc-editor.org/info/rfc3986>. ๐ŸŒ

[RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, September 2009, <https://www.rfc-editor.org/info/rfc5646>. ๐Ÿณ๏ธโ€๐ŸŒˆ

[RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, RFC 5652, DOI 10.17487/RFC5652, September 2009, <https://www.rfc-editor.org/info/rfc5652>. ๐Ÿ—๏ธ

[RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, DOI 10.17487/RFC6265, April 2011, <https://www.rfc-editor.org/info/rfc6265>. ๐Ÿช

[RFC6381] Gellens, R., Singer, D., and P. Frojdh, "The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types", RFC 6381, DOI 10.17487/RFC6381, August 2011, <https://www.rfc-editor.org/info/rfc6381>. ๐Ÿชฃ

[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014, <https://www.rfc-editor.org/info/rfc7159>. ๐Ÿงพ

[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014, <https://www.rfc-editor.org/info/rfc7230>. ๐Ÿ“จ

[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>. ๐Ÿ” 

[SCTE35] Society of Cable Telecommunications Engineers, "Digital Program Insertion Cueing Message for Cable", ANSI/SCTE 35, August 2014, <http://www.scte.org/documents/pdf/Standards/ANSI_SCTE%2035%202014.pdf>. โœ‚๏ธ

[US_ASCII] American National Standard for Information Systems, "Coded Character Sets - 7-Bit American National Standard Code for Information Interchange (7-Bit ASCII)", ANSI X3.4, December 1986. ๐Ÿ”ก

[WebVTT] World Wide Web Consortium (W3C), "WebVTT: The Web Video Text Tracks Format", Draft Community Group Report, June 2017, <http://dev.w3.org/html5/webvtt/>. ๐Ÿ“


11.2. Informative References

Okay these ones are the "good to know" crew, not strictly required, but they add so much context ๐Ÿง โœจ

[CMAF] International Organization for Standardization, "Information technology -- Multimedia application format (MPEG-A) -- Part 19: Common media application format (CMAF) for segmented media", ISO/IEC FDIS 23000-19, <https://www.iso.org/standard/71975.html>. ๐ŸŽ€

[ID3] ID3.org, "The ID3 audio file data tagging format", <http://www.id3.org/Developer_Information>. ๐Ÿท๏ธ

[M3U] Nullsoft, Inc., "The M3U Playlist format, originally invented for the Winamp media player", <https://en.wikipedia.org/w/index.php?title=M3U7amp;oldid=786631666>. ๐ŸŽต

[SampleEnc] Apple Inc., "MPEG-2 Stream Encryption Format for HTTP Live Streaming", <https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption/>. ๐ŸŽ

[UNICODE] The Unicode Consortium, "The Unicode Standard", <http://www.unicode.org/versions/latest/>. ๐ŸŒ

[UTI] Apple Inc., "Uniform Type Identifier", <http://developer.apple.com/library/ios/#documentation/general/conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html>. ๐Ÿ—‚๏ธ


Contributors

Significant contributions to the design of this protocol were made by Jim Batson, David Biderman, Bill May, Roger Pantos, Alan Tseng, and Eryk Vershen. Stuart Cheshire helped edit the specification. ๐Ÿซถ๐Ÿ’œ


Authors' Addresses

Roger Pantos (editor) Apple, Inc. Cupertino, California United States of America Email: http-live-streaming-review@group.apple.com ๐ŸŽ

William May, Jr. Major League Baseball Advanced Media New York, New York United States of America Email: bill.may@mlb.com โšพ

๐Ÿ“ฆ where this page comes from