M3U8 File Format: Structure and Key Tags Explained
Deep dive into the M3U8 file format. Every tag and attribute in the HLS playlist specification explained with examples.
M3U8 File Structure Overview
An M3U8 file has a simple line-by-line structure. Each line is either a tag (starts with #) or a URI (a path or URL to a segment or another playlist). The structure varies depending on whether it's a master playlist or a media playlist.
Master Playlist Structure
A master playlist contains references to multiple variant streams:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=1280000,RESOLUTION=720x480,CODECS="avc1.66.30,mp4a.40.2"
medium.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2560000,RESOLUTION=1280x720,CODECS="avc1.77.30,mp4a.40.2"
high.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5120000,RESOLUTION=1920x1080,CODECS="avc1.77.30,mp4a.40.2"
fullhd.m3u8
Media Playlist Structure
A media playlist contains the actual segment references:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.000,
seg-0.ts
#EXTINF:10.000,
seg-1.ts
#EXTINF:10.000,
seg-2.ts
#EXT-X-ENDLIST
Essential Tags Reference
| Tag | Purpose | Required |
|---|---|---|
| #EXTM3U | File header (must be first line) | ✅ |
| #EXT-X-VERSION | Protocol version number | ✅ |
| #EXT-X-TARGETDURATION | Maximum segment duration | ✅ |
| #EXTINF | Segment duration and title | ✅ |
| #EXT-X-MEDIA-SEQUENCE | First segment number | ⚠️ |
| #EXT-X-KEY | Encryption key info | ⚠️ |
| #EXT-X-STREAM-INF | Variant stream description | ⚠️ |
| #EXT-X-ENDLIST | Signals end of VOD | ⚠️ |
Common Errors in M3U8 Files
- Missing #EXTM3U header — The file won't be recognized as a valid playlist
- Incorrect segment paths — Relative paths may break if the playlist URL changes
- Mismatched target duration — If a segment exceeds TARGETDURATION, players may misbehave
- Missing ENDLIST for VOD — Players will keep waiting for new segments indefinitely
- Encoding errors — Files must be UTF-8 (or ASCII for basic M3U)
Related Articles
What Is an M3U8 File? Complete Guide to the HLS Playlist Format
Learn what an M3U8 file is, how it works with HLS streaming, and how to open, edit, and create M3U8 playlists.
M3U8 vs MP4: What's the Difference?
Understand the key differences between M3U8 playlist files and MP4 video files. When to use each format for video delivery.
M3U8 vs M3U: What's the Difference?
Learn the differences between M3U and M3U8 playlist formats. Encoding, compatibility, and when to use each format.