M3U File Format: From Simple Playlists to HLS Streaming
The M3U format is a widely used, de facto standard for creating media playlists. At its core, an M3U file is a plain text document that tells a media player where to find one or more audio or video files. Because it is simple and flexible, it has evolved from a basic list of local files into the foundation for modern internet streaming technologies.
Depending on the character encoding used, these files carry different extensions. A file saved with the .m3u extension typically uses the local system's default non-Unicode encoding (such as a Windows codepage). In contrast, files encoded in UTF-8—a universal character encoding standard—use the .m3u8 extension. While the .mp3url extension was once supported by Winplay3, it is no longer in common use.
Each entry in a standard M3U file provides a single location specification, which can be an absolute local pathname (e.g., C:\My Music\Heavysets.mp3), a relative local pathname (e.g., Heavysets.mp3), or a URL. Each entry must end with a line break; notably, some devices require the specific CR LF (Carriage Return Line Feed) sequence and may not recognize a single LF (Line Feed).
Key Facts
- De Facto Standard: M3U has no formal specification but is universally accepted by media players.
- Encoding Matters:
.m3uis for system-default encoding, while.m3u8is mandatory for UTF-8. - Versatility: Supports local file paths, relative paths, and web URLs.
- Foundation for HLS: Apple's HTTP Live Streaming (HLS) is based on the extended M3U format.
- IPTV Integration: Used extensively in IPTV to organize channel streams and metadata.
Extended M3U
To provide more than just a list of paths, the Extended M3U format introduces comments and directives. These are identified by the # character. Directives that support parameters are terminated by a colon (:).
Common Extended M3U Directives
The following table outlines the most frequent directives used to add metadata to playlists:
| Directive | Description | Example | Standard/Usage |
|---|---|---|---|
#EXTM3U |
Mandatory file header; must be the first line. | #EXTM3U |
Standard |
#EXTINF: |
Track info: runtime (seconds) and optional title. Use -1 or 0 for streams. | #EXTINF:123,Artist - Title |
Standard |
#PLAYLIST: |
The display title of the playlist. | #PLAYLIST:Music TV |
IPTV |
#EXTGRP: |
Begins a named group of channels. | #EXTGRP:Foreign Channels |
IPTV |
#EXTALB: |
Album title information. | #EXTALB:Album Title (2009) |
AL, M3A |
#EXTVLCOPT: |
Sets specific VLC player options. | #EXTVLCOPT:start-time=32.5 |
VLC |
HTTP Live Streaming (HLS)
Apple adapted the UTF-8 encoded extended M3U format to create HTTP Live Streaming (HLS), which was documented as RFC 8216 in 2017. HLS uses a hierarchical structure where a master playlist references several segment playlists. These segment playlists contain URLs for short fragments of the media stream.
HLS directives are distinguished by the #EXT-X- prefix. Key directives include #EXT-X-TARGETDURATION (the maximum segment length in seconds), #EXT-X-VERSION, and #EXT-X-STREAM-INF, which provides bandwidth and codec information for different stream qualities.
M3U in IPTV
In Internet Protocol Television (IPTV), M3U playlists act as channel lists where each entry is a stream URL. For these continuous streams, the #EXTINF: length is typically set to -1.
Unlike HLS, IPTV uses a key-value syntax within the #EXTINF line to provide structured data before the mandatory comma. Common attributes include:
- Group:
group-titleortvg-groupfor thematic categorization. - Logo:
tvg-logoprovides a URL to the channel's image. - Identification:
tvg-id(CUID) links the stream to Electronic Program Guide (EPG) data. - Localization:
tvg-country(ISO 3166) andtvg-language(ISO 639). - Type:
radio=truemarks the entry as an audio-only channel.
Frequently Asked Questions
What is the difference between .m3u and .m3u8?
The difference lies in the character encoding. .m3u files use the system's default local encoding, while .m3u8 files must be encoded in UTF-8 to ensure compatibility across different platforms and languages.
Is M3U a formal technical standard?
No, M3U is a de facto standard, meaning it is widely accepted and used by the industry without being defined by a formal governing body, although specific implementations like HLS are documented in RFCs.
How does HLS use the M3U format?
HLS uses a modified version of the extended M3U format (UTF-8) to create master and segment playlists. It uses specific tags starting with #EXT-X- to manage media segments, bandwidth, and encryption.
What does the #EXTINF: -1 value mean in IPTV?
In the context of IPTV and continuous streaming, a length of -1 (or 0) indicates that the media is a live stream with no predefined total duration.
Can M3U files contain binary data?
While standard M3U files are plain text, the #EXTBIN: directive in some versions (like M3A) indicates that binary data, such as concatenated MP3s, follows the directive.