HLS is described by RFC 8216 (2017) and its successor, the Internet-Draft
draft-pantos-hls-rfc8216bis, now at revision 22. This reference follows
the draft, which adds low latency, content steering and many attributes, and marks
the protocol version each feature needs.
The file
| Rule | Detail |
|---|---|
| Name and type | The path ends in .m3u8 or .m3u, or the HTTP type is application/vnd.apple.mpegurl (registered) or audio/mpegurl. |
| First line | #EXTM3U (23 45 58 54 4D 33 55), required. |
| Encoding | UTF-8 in Unicode normal form C, with no byte order mark. No control characters except CR and LF. |
| Lines | End with LF or CR LF. Each line is a URI, blank (ignored), or starts with #. No white space except where a tag allows it. |
| Tags | Lines starting #EXT, case-sensitive. Unknown tags are ignored. |
| Comments | Any other line starting #. |
| URIs | Addresses of segments or playlists, relative to the playlist’s own address. |
A playlist is either a media playlist, listing segments, or a multivariant playlist (the master playlist of RFC 8216), listing other playlists. One holding tags of both kinds is invalid; one holding neither counts as an empty multivariant playlist.
Attribute lists
Many tags take an attribute list: NAME=value pairs separated by commas,
with no spaces, such as
#EXT-X-KEY:METHOD=AES-128,URI="key.bin". Names use only
A–Z, 0–9 and -, and
may not repeat within one list.
| Value type | Form | Example |
|---|---|---|
| decimal-integer | 1 to 20 digits, 0 to 264−1 | 1280000 |
| hexadecimal-sequence | 0x or 0X, then hexadecimal digits | 0x9c7db8778570d05c3177c349fd9236aa |
| decimal-floating-point | digits and a full stop, not negative | 6.006 |
| signed-decimal-floating-point | the same, optionally negative | -12.5 |
| quoted-string | in double quotes, no CR, LF or "; compared byte by byte | "English" |
| enumerated-string | a keyword without quotes | YES |
| enumerated-string-list | keywords separated by commas, in quotes; unknown ones ignored | "PRE,ONCE" |
| decimal-resolution | width x height | 1920x1080 |
Variables
From version 8, a playlist can define variables and use them as
{$name} in URI lines, quoted strings and hexadecimal values. Names use
A–Z, a–z, 0–9,
- and _, and are case-sensitive.
| Form | Value comes from |
|---|---|
NAME="n",VALUE="v" | The playlist itself. VALUE may be empty. |
IMPORT="n" | The variable of that name in the multivariant playlist that led here. Only in media playlists. |
QUERYPARAM="n" | The query parameter of that name in the playlist’s own URI, percent-decoded (version 11). |
A reference to an undefined variable, or a name defined twice, makes the playlist fail to parse.
Protocol versions
| Version | Needed for |
|---|---|
| 1 | The basic tags |
| 2 | The IV attribute of EXT-X-KEY |
| 3 | Durations with decimals in EXTINF |
| 4 | EXT-X-BYTERANGE, EXT-X-I-FRAMES-ONLY |
| 5 | METHOD=SAMPLE-AES, KEYFORMAT, KEYFORMATVERSIONS, EXT-X-MAP in an I-frame playlist |
| 6 | EXT-X-MAP in any other media playlist. The PROGRAM-ID attribute was removed. |
| 7 | INSTREAM-ID="SERVICEn" closed captions. The EXT-X-ALLOW-CACHE tag was removed. |
| 8 | Variable substitution |
| 9 | EXT-X-SKIP |
| 10 | EXT-X-SKIP that also removes date ranges |
| 11 | EXT-X-DEFINE with QUERYPARAM |
| 12 | Attributes whose names start REQ-, such as REQ-VIDEO-LAYOUT |
| 13 | INSTREAM-ID on an EXT-X-MEDIA that is not closed captions |
Worked example
#EXTM3U
#EXT-X-VERSION:11
#EXT-X-DEFINE:QUERYPARAM="token"
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-START:TIME-OFFSET=-12.0,PRECISE=YES
#EXT-X-TARGETDURATION:6
#EXTINF:6.0,
segment100.m4s?token={$token}
token query parameter
from its own address into each segment address, and asks players to start exactly
12 seconds before the end.