m3u8 is a playlist file format used in the HTTP Live Streaming (HLS) protocol, based on the UTF-8 encoded m3u playlist. The m3u8 file is essentially a text file containing metadata and segment information of the media stream, enabling clients to dynamically adapt to video streams under different bandwidth conditions.
The simplest m3u8 file must start with the #EXTM3U tag, which is the identifier of the m3u8 file:
#EXTM3U
The master playlist contains multiple stream versions with different bitrates, allowing clients to automatically select the most suitable stream based on network conditions:
#EXTM3U #EXT-X-VERSION:6 # Video Stream #EXT-X-STREAM-INF:BANDWIDTH=1500000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2" video_low.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=854x480,CODECS="avc1.4d401f,mp4a.40.2" video_medium.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2" video_high.m3u8 #EXT-X-I-FRAME-STREAM-INF:RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=92606,AVERAGE-BANDWIDTH=47706,URI="video_high_I-Frame.m3u8"
#EXT-X-VERSION: Specifies the HLS protocol version. If ≥7, it is fmp4 encapsulation; if ≤6, the encapsulation form cannot be determined and needs to be checked for #EXT-X-MAP
#EXT-X-STREAM-INF: Describes the attributes of the subsequent stream, including:
avc: h264 encoding
hvc: h265 encoding
dvc: h265 Dolby Vision encoding
mp4a: Audio AAC encoding, suitable for music, podcasts, short videos
ac-3: Audio Dolby Digital, suitable for DVDs, SD TV
ec-3: Audio Enhanced Dolby, suitable for Blu-ray, 4K streaming, cinemas
BANDWIDTH: Bandwidth requirement (bits/second)
RESOLUTION: Resolution
CODECS: Codec information, common codec information includes:
#EXT-X-I-FRAME-STREAM-INF This content is the #EXT-X-I-FRAME-STREAM-INF tag in the M3U8 playlist used to describe keyframe (I-Frame) stream information, mainly used to support fast positioning, preview, or thumbnail generation for videos. The following are the specific meanings of each parameter:
BANDWIDTH: Bandwidth requirement (bits/second)
RESOLUTION: Resolution
CODECS: Codec information, common codec information includes:
AVERAGE-BANDWIDTH=47706: The average bandwidth requirement of this keyframe stream, in bps, is a reference for the player when selecting streams (compared to the peak value, it better reflects overall bandwidth consumption)
URI: Points to the index file address of this keyframe stream. This index file (video_high_I-Frame.m3u8) contains information about the specific positions and durations of all keyframes. The player can directly obtain keyframe data at the target time point through it.
The media playlist contains information about actual media segments:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:10.0, segment0.ts #EXTINF:10.0, segment1.ts #EXTINF:10.0, segment2.ts #EXT-X-ENDLIST
Key tag descriptions:
#EXT-X-TARGETDURATION: Specifies the maximum duration of each segment (seconds)
#EXT-X-MEDIA-SEQUENCE: The sequence number of the first segment in the playlist
#EXTINF: Segment duration, followed by the segment filename
#EXT-X-ENDLIST: Indicates the playlist will no longer be updated (if present, it indicates VOD on-demand; live streams do not have this field)
To improve efficiency and compatibility, and to support HEVC (H265) playback, Apple released HLS 7.0 (#EXT-X-VERSION=7) at the 2017 WWDC conference, beginning support for fMP4 (Fragmented MP4) based segments. fMP4 is a fragmented version of the MP4 format, where each segment is an independent, playable MP4 file. It not only has lower encapsulation overhead but also better integrates with the MPEG-DASH protocol. Later, based on fMP4, it further supported the CMAF encapsulation standard. After adopting the CMAF standard, content providers only need to encode and store one video file to serve both HLS and DASH clients simultaneously, greatly saving storage and CDN costs.
For fMP4 and CMAF containers, the m3u8 file will contain the #EXT-X-MAP tag, used to specify the initialization segment, which is the key to parsing fMP4.
The initialization segment is usually an independent, small file containing the moov atom in the ISO Base Media File Format (i.e., MP4 container format).
Example as follows:
#EXT-X-MAP:URI="init.mp4"
You can view its detailed information using tools like ffprobe. Command as follows:
ffprobe -v error -show_format -show_streams init.mp4
Displayed content example as follows:
[STREAM] index=0 codec_name=h264 codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 ... [FORMAT] filename=init.mp4 format_name=mov,mp4,m4a,3gp,3g2,mj2 format_long_name=QuickTime / MOV ... [/FORMAT]
codec_name, displays encoding format: h264, H265
format_name field,
If it is mp4 or mov,mp4,m4a,3gp,3g2,mj2, it is fMP4.
If it is mpegts, it is TS encapsulation.
Key Information
HLS supports multiple subtitle formats, including WebVTT, TTML, and CEA-608/708. Subtitles are implemented by defining the EXT-X-MEDIA tag in the master playlist:
#EXTM3U #EXT-X-VERSION:6 # Video Stream #EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=854x480 video_medium.m3u8 # Subtitle Track - English #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES, FORCED=NO,LANGUAGE="en",URI="subtitles_en.m3u8" # Subtitle Track - Chinese #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="中文",DEFAULT=NO, FORCED=NO,LANGUAGE="zh",URI="subtitles_zh.m3u8" # Subtitle Track - Japanese #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="日本語",DEFAULT=NO, FORCED=NO,LANGUAGE="ja",URI="subtitles_ja.m3u8"
Subtitle playlist example (WebVTT format):
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD # Specify WebVTT format #EXT-X-SUBTITLES-FORMAT:WEBVTT #EXT-X-SUBTITLES-LANGUAGE:en #EXTINF:10.000, subtitle0.vtt #EXTINF:10.000, subtitle1.vtt #EXTINF:10.000, subtitle2.vtt #EXT-X-ENDLIST
In M3U8 (HLS protocol), support for "Chapters" is mainly implemented through the #EXT-X-CHAPTER series tags, used to divide video content into multiple logical chapters (such as intro, main feature acts, outro, etc.), facilitating the player to display chapter lists and quick jumps. These tags are defined in HLS protocol version 8 and above (EXT-X-VERSION:8+).
| Tag | Function |
|---|---|
#EXT-X-CHAPTER | Marks the start of a chapter, needs to be combined with URI or TIME-OFFSET to define the chapter position |
#EXT-X-CHAPTER-ID | Specifies a unique ID for the chapter (optional, used to identify the chapter) |
#EXT-X-CHAPTER-DURATION | Defines the duration of the chapter (optional, unit: seconds, accurate to 9 decimal places) |
#EXT-X-CHAPTER-TITLE | Defines the title of the chapter (optional, used for player display, supports UTF-8 characters) |
#EXT-X-CHAPTER-URI | Points to the media segment corresponding to the chapter (optional, if the chapter corresponds to an independent media stream) |
#EXT-X-CHAPTER-TIME-OFFSET | Defines the start time offset of the chapter in the main media stream (relative to the start of the stream, unit: seconds) |
Chapters are divided based on the timeline of the main media stream, no additional media files are needed, only the start position is defined via TIME-OFFSET.
#EXTM3U #EXT-X-VERSION:8 # Must use version 8 and above #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 # Chapter 1: Intro (starts at 0 seconds, lasts 30 seconds) #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:chapter1 #EXT-X-CHAPTER-TITLE:Intro #EXT-X-CHAPTER-TIME-OFFSET:0.0 #EXT-X-CHAPTER-DURATION:30.0 # Chapter 2: Main Feature Act 1 (starts at 30 seconds, lasts 120 seconds) #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:chapter2 #EXT-X-CHAPTER-TITLE:Main Feature - Act 1 #EXT-X-CHAPTER-TIME-OFFSET:30.0 #EXT-X-CHAPTER-DURATION:120.0 # Chapter 3: Outro (starts at 150 seconds, lasts 20 seconds) #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:chapter3 #EXT-X-CHAPTER-TITLE:Outro #EXT-X-CHAPTER-TIME-OFFSET:150.0 #EXT-X-CHAPTER-DURATION:20.0 # Main media stream segments (covering the time range of all chapters) #EXTINF:10.0, segment_0.ts #EXTINF:10.0, segment_1.ts #EXTINF:10.0, segment_2.ts #EXTINF:10.0, segment_3.ts #EXTINF:10.0, segment_4.ts #EXTINF:10.0, segment_5.ts #EXTINF:10.0, segment_6.ts #EXTINF:10.0, segment_7.ts #EXTINF:10.0, segment_8.ts #EXTINF:10.0, segment_9.ts #EXT-X-ENDLIST
Chapters point to independent media segment files via URI, suitable for scenarios where chapter content is separated (such as separate encoding for multiple chapters).
#EXTM3U #EXT-X-VERSION:8 #EXT-X-TARGETDURATION:10 # Chapter 1: Independent intro media stream #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:intro #EXT-X-CHAPTER-TITLE:Intro #EXT-X-CHAPTER-URI:chapters/intro.m3u8 # Points to the sub-M3U8 of the intro #EXT-X-CHAPTER-DURATION:30.0 # Chapter 2: Independent main feature media stream #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:main #EXT-X-CHAPTER-TITLE:Main Feature #EXT-X-CHAPTER-URI:chapters/main.m3u8 # Points to the sub-M3U8 of the main feature #EXT-X-CHAPTER-DURATION:600.0 # Chapter 3: Independent outro media stream #EXT-X-CHAPTER #EXT-X-CHAPTER-ID:outro #EXT-X-CHAPTER-TITLE:Outro #EXT-X-CHAPTER-URI:chapters/outro.m3u8 # Points to the sub-M3U8 of the outro #EXT-X-CHAPTER-DURATION:20.0 #EXT-X-ENDLIST
Version Requirement: Must be used in EXT-X-VERSION:8 and above, lower versions do not support chapter tags.
Player Compatibility: Not all HLS players support chapter display (e.g., some older players may ignore chapter tags), mainstream players (such as Safari, VLC, latest ExoPlayer) usually support it.
Tag Order: Chapter tags need to be placed before the media segment list (before #EXTINF), to ensure the player parses chapter information first.
Time Precision: TIME-OFFSET and DURATION support 9 decimal places, accurate to the nanosecond level, adapting to high frame rate videos.
Through chapter tags, functions similar to local video player "chapter navigation" can be achieved, enhancing the interactive experience of long videos (such as movies, courses).
The ad insertion standard SCTE-35 mapping in HLS. Their core function is to define the time points for "main content interruption (insert ad)" and "ad end (resume main content)"
The following two tags originate from support for SCTE-35 signals (broadcast-level ad insertion control signals), mainly used for dynamic ad insertion (DAI) in streaming media. Specific logic:
#EXT-X-CUE-OUT:<duration>: Marks that the main content is interrupted here, start inserting ads, duration is the estimated total duration of the ad (seconds).
#EXT-X-CUE-IN: Marks the end of ad insertion, resume main content playback.
Example as follows:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 # Main content segments #EXTINF:10.0, main_0.ts #EXTINF:10.0, main_1.ts # Mark main content interruption, insert 15 seconds of ads #EXT-X-CUE-OUT:15.0 #EXTINF:5.0, ad_0.ts # Ad segment 1 #EXTINF:5.0, ad_1.ts # Ad segment 2 #EXTINF:5.0, ad_2.ts # Ad segment 3 # Mark ad end, resume main content #EXT-X-CUE-IN #EXTINF:10.0, main_2.ts #EXTINF:10.0, main_3.ts #EXT-X-ENDLIST
VOD Streams contain the #EXT-X-ENDLIST tag, indicating a complete playlist:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD ... #EXT-X-ENDLIST
Live Streams do not contain an end tag and require clients to periodically refresh to get new segments:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:2680 #EXTINF:10.0, segment2680.ts #EXTINF:10.0, segment2681.ts
m3u8 supports media encryption, providing basic content protection:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-KEY:METHOD=AES-128,URI="key.php",IV=0x9c7db8778570d05c2a4d7d5a7f5c8d9c #EXTINF:10.0, segment0.ts
Encryption-related tags:
METHOD: Encryption method (NONE, AES-128, SAMPLE-AES)
URI: Key acquisition address
IV: Initialization vector (optional)
Allows a single file to contain multiple segments, saving request overhead:
#EXTM3U #EXT-X-VERSION:6 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-BYTERANGE:82112@0 #EXTINF:10.0, video.ts #EXT-X-BYTERANGE:83232@82112 #EXTINF:10.0, video.ts
The following is a simple Node.js example demonstrating how to generate an m3u8 file containing subtitle and ad information:
function generateMasterPlaylist(videoStreams, subtitles) {
let m3u8 = '#EXTM3U\n';
m3u8 += '#EXT-X-VERSION:6\n';
// Add video streams
videoStreams.forEach(stream => {
m3u8 += `#EXT-X-STREAM-INF:BANDWIDTH=${stream.bandwidth},RESOLUTION=${stream.resolution}\n`;
m3u8 += `${stream.uri}\n`;
});
// Add subtitle tracks
subtitles.forEach(sub => {
m3u8 += `#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="${sub.name}",DEFAULT=${sub.default ? 'YES' : 'NO'},LANGUAGE="${sub.language}",URI="${sub.uri}"\n`;
});
return m3u8;
}
function generateMediaPlaylistWithChapters(segments, chapters) {
let m3u8 = '#EXTM3U\n';
m3u8 += '#EXT-X-VERSION:6\n';
m3u8 += `#EXT-X-TARGETDURATION:${segments[0].duration}\n`;
m3u8 += `#EXT-X-MEDIA-SEQUENCE:0\n`;
let currentTime = 0;
let chapterIndex = 0;
segments.forEach((segment, index) => {
// Check if ad marker needs to be added
if (adIndex < ads.length &&
currentTime >= ads[adIndex].startTime) {
m3u8 += `#EXT-X-CUE-OUT:${ads[adIndex].duration}\n`;
adIndex++;
}
m3u8 += `#EXTINF:${segment.duration},\n`;
m3u8 += `${segment.uri}\n`;
currentTime += segment.duration;
});
m3u8 += '#EXT-X-ENDLIST\n';
return m3u8;
}Developers can use the following tools to validate m3u8 files:
FFmpeg:
ffmpeg -i input.m3u8 -c copy output.mp4
hls.js: HLS client library for the Web, suitable for debugging playback issues
Apple's mediastreamvalidator: Official validation tool
VLC Media Player: Supports playing HLS streams and displaying subtitle and chapter information
Segment duration is recommended to be set between 6-10 seconds
Ensure #EXT-X-TARGETDURATION equals or is slightly greater than the actual longest segment
For live streams, keep the playlist length moderate (usually containing 4-6 recent segments)
Use CDN to accelerate segment file distribution
Consider enabling Gzip compression to reduce m3u8 file size
Provide multi-language support for subtitles and set appropriate DEFAULT tracks
Chapter markers should be precisely aligned with I-frames to avoid inaccurate player jumps
Playback Failure: Check m3u8 file paths and segment file accessibility
Stuttering: Check if segment durations are consistent and if network bandwidth is sufficient
Encryption Issues: Confirm the key server is accessible and returns keys in the correct format
Subtitles Not Displaying: Check subtitle file formats and MIME type settings
Inaccurate Chapter Markers: Ensure chapter start times align with keyframes
Below is an example to illustrate, address: https://d2zihajmogu5jn.cloudfront.net/elephantsdream/hls/ed_hd.m3u8
Content as follows:
#EXTM3U #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog,public.accessibility.describes-music-and-sound",URI="manifest9/captions.en.m3u8" #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Swedish",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="sv",URI="manifest10/captions.sv.m3u8" #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Russian",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ru",URI="manifest11/captions.ru.m3u8" #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Japanese",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ja",URI="manifest12/captions.ja.m3u8" #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Arabic",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ar",URI="manifest13/captions.ar.m3u8" #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ed_audio_64k",LANGUAGE="en",NAME="Main",CHANNELS="2",AUTOSELECT=YES,DEFAULT=YES,URI="manifest5/index.m3u8" #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ed_audio_64k",LANGUAGE="en",NAME="Audio Described",CHANNELS="2",AUTOSELECT=YES,DEFAULT=NO,CHARACTERISTICS="public.accessibility.describes-video",URI="manifest6/index.m3u8" #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ed_audio_128k",LANGUAGE="en",NAME="Main",CHANNELS="2",AUTOSELECT=YES,DEFAULT=YES,URI="manifest7/index.m3u8" #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="ed_audio_128k",LANGUAGE="en",NAME="Audio Described",CHANNELS="2",AUTOSELECT=YES,DEFAULT=NO,CHARACTERISTICS="public.accessibility.describes-video",URI="manifest8/index.m3u8" #EXT-X-STREAM-INF:BANDWIDTH=2100000,AVERAGE-BANDWIDTH=800000,CODECS="mp4a.40.2, avc1.4d001e",RESOLUTION=480x270,FRAME-RATE=24,AUDIO="ed_audio_64k",SUBTITLES="subs" manifest0/index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=3300000,AVERAGE-BANDWIDTH=1050000,CODECS="mp4a.40.2, avc1.4d001f",RESOLUTION=640x360,FRAME-RATE=24,AUDIO="ed_audio_64k",SUBTITLES="subs" manifest1/index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=6000000,AVERAGE-BANDWIDTH=2000000,CODECS="mp4a.40.2, avc1.4d0028",RESOLUTION=854x480,FRAME-RATE=24,AUDIO="ed_audio_64k",SUBTITLES="subs" manifest2/index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=10000000,AVERAGE-BANDWIDTH=3000000,CODECS="mp4a.40.2, avc1.640028",RESOLUTION=1280x720,FRAME-RATE=24,AUDIO="ed_audio_128k",SUBTITLES="subs" manifest3/index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=21000000,AVERAGE-BANDWIDTH=6000000,CODECS="mp4a.40.2, avc1.64002a",RESOLUTION=1920x1080,FRAME-RATE=24,AUDIO="ed_audio_128k",SUBTITLES="subs" manifest4/index.m3u8
This is a very typical and fully functional HLS master playlist. It defines a complex media presentation containing multi-bitrate video streams, multi-language subtitles, and multi-version audio tracks.
The following will explain its content in detail part by part:
#EXTM3U: Indicates this is an M3U playlist file.
#EXT-X-MEDIA:TYPE=SUBTITLES)This part defines 5 different language subtitle tracks, all belonging to the same group GROUP-ID="subs".
English Subtitles (English)
TYPE=SUBTITLES: Media type is subtitles.
GROUP-ID="subs": Group identifier, video streams will reference this ID to associate subtitles.
NAME="English": Name displayed to the user.
DEFAULT=YES: Selected by default. The player will automatically load this subtitle track upon first load.
AUTOSELECT=YES: If the player's language setting matches the user preference, this track will be automatically selected.
FORCED=NO: This is not a forced subtitle (such as subtitles containing only background sound translations).
LANGUAGE="en": Language code.
CHARACTERISTICS="...": Describes the characteristics of this subtitle (can transcribe dialogue, describe music and sound effects), this is an accessibility feature.
URI="manifest9/captions.en.m3u8": Points to the playlist containing actual subtitle segments (such as WebVTT files).
Swedish, Russian, Japanese, Arabic Subtitles
Parameters are similar to English subtitles, but DEFAULT=NO (not default), and do not have the CHARACTERISTICS attribute.
They each have corresponding language codes and dedicated playlist URIs.
Summary: Users can choose subtitles from 5 languages (English, Swedish, Russian, Japanese, Arabic) in the player, with English being the default option.
#EXT-X-MEDIA:TYPE=AUDIO)This part defines two groups of audio tracks with different bitrates, each group containing two versions: main audio track and audio described track.
Group 1: 64kbps Audio Group (GROUP-ID="ed_audio_64k")
Main Audio Track (Main)
TYPE=AUDIO: Media type is audio.
GROUP-ID="ed_audio_64k": Group identifier.
LANGUAGE="en": English.
NAME="Main": Name is "Main Audio Track".
CHANNELS="2": Dual-channel stereo.
DEFAULT=YES: Default selection in this group.
URI="manifest5/index.m3u8": Points to the playlist for the 64kbps main audio track.
Audio Described Track (Audio Described)
NAME="Audio Described": This is the audio description version provided for visually impaired users, which describes scenes, actions, and expressions during gaps in video dialogue.
CHARACTERISTICS="public.accessibility.describes-video": Explicitly indicates its accessibility feature.
DEFAULT=NO: Not the default option.
Other attributes are the same as the main audio track.
Group 2: 128kbps Audio Group (GROUP-ID="ed_audio_128k")
The structure is identical to Group 1, but with a higher bitrate (theoretically better sound quality), and the corresponding playlist URIs are also different (manifest7/ and manifest8/).
Summary: Provides audio in two qualities (64kbps and 128kbps), and for each quality, users can choose to listen to the standard main audio track or the auxiliary track with video descriptions.
#EXT-X-STREAM-INF)This part defines 5 video streams with different bitrates and resolutions. The player will automatically select the most suitable one for playback based on current network bandwidth. All video streams do not contain audio (audio is associated through the AUDIO property later).
270p Low Bitrate Stream
mp4a.40.2: AAC-LC audio codec (but this video stream contains no audio, this codec information refers to the format of the audio stream it needs to associate).
avc1.4d001e: H.264 video codec profile and level, corresponding to SD resolution.
BANDWIDTH=2100000: Peak bandwidth approximately 2.1 Mbps.
AVERAGE-BANDWIDTH=800000: Average bandwidth approximately 0.8 Mbps.
CODECS="mp4a.40.2, avc1.4d001e": Specifies codecs.
RESOLUTION=480x270: Resolution 480x270 (270p).
FRAME-RATE=24: Frame rate 24 fps.
AUDIO="ed_audio_64k": Associate audio group. When this video stream is selected, the player will load the audio from GROUP-ID="ed_audio_64k".
SUBTITLES="subs": Associate subtitle group. Indicates that the available subtitle tracks are the group with GROUP-ID="subs".
manifest0/index.m3u8: Points to the media playlist file corresponding to this bitrate stream.
360p, 480p, 720p, 1080p Streams
The parameter patterns of the subsequent four streams are similar: bitrate, resolution, and video codec level (avc1.4d001f -> avc1.64002a) gradually increase to provide higher quality video.
Key Difference: The first three lower bitrate streams (270p, 360p, 480p) are associated with the ed_audio_64k audio group, while the two higher bitrate streams (720p, 1080p) are associated with the ed_audio_128k audio group. This is an optimization strategy, pairing high-definition video with higher quality audio.
Player Loads: The player first loads this master playlist file.
Get Available Options: Parses the list, learning there are 5 video bitrates, 2 sound qualities (2 versions in each group), and 5 subtitles available.
Adaptive Selection:
The player selects the most suitable one from the 5 video streams based on current network bandwidth (e.g., if network speed is good, select the 1080p stream of manifest4/index.m3u8).
Selects the corresponding audio track (e.g., "Main" track in the ed_audio_128k group) and subtitles (e.g., "English") based on user settings or defaults.
Parallel Loading: The player simultaneously loads the selected video stream media list, audio stream media list, and subtitle media list, then downloads the corresponding audio, video, and subtitle segments for synchronized playback.
Dynamic Switching: If network conditions change, the player will automatically switch seamlessly between video streams of different bitrates.
This m3u8 file reflects a very professional and user-friendly streaming media configuration, fully considering the experience under different network conditions, multi-language users, and accessibility needs for the visually impaired.
As the core of the HLS protocol, m3u8 provides powerful adaptive streaming media capabilities, including rich subtitle and chapter support. Understanding its file format and the meaning of various tags is crucial for developing streaming media applications. As HLS technology continues to evolve, developers are advised to continuously pay attention to new tags and features to provide better streaming media experiences.
Through the introduction in this article, you should have a comprehensive understanding of the m3u8 file format, capable of creating, parsing, and debugging HLS streaming media playlists containing subtitles and chapters.
The zwplayer player is one of the few online web players that supports m3u8 format multi-bitrate adaptive playback and embedded subtitle playback. Everyone is welcome to use it 😀
Post a Comment