HLS.js Guide and Best Practices
Master the core technology of HLS streaming media playback, including complete code examples and solutions to common issues.
Read More →Comprehensive understanding of the M3U8 format — master all the ways to open and play M3U8 files
M3U8 is the Unicode version of the M3U playlist file format, using UTF-8 encoding. It was originally designed as a playlist format for audio players like Winamp, and was later adopted and refined by Apple for use in HLS (HTTP Live Streaming) streaming technology, becoming one of the most mainstream streaming media playlist formats today.
Simply put, an M3U8 file itself does not contain audio or video data — it is a plain text playlist file that records metadata such as video segment addresses, durations, and encryption information. Players parse the M3U8 file and sequentially download and play the video segments referenced within it.
M3U8 is the core component of HLS technology. The basic idea of HLS is to split the entire video into multiple small TS segment files, each typically 2–10 seconds long, and then manage these segments through an M3U8 playlist file.
M3U8 playlists are divided into two types: Master Playlist and Media Playlist.
The master playlist contains multiple media playlist addresses with different bitrates and resolutions, used to implement adaptive bitrate playback. The player automatically selects the most appropriate quality based on current network bandwidth.
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=854x480
480p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
720p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p/index.m3u8
The media playlist contains the actual video segment addresses and duration information — it is the actual playlist used for playback.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
segment0.ts
#EXTINF:10.0,
segment1.ts
#EXTINF:10.0,
segment2.ts
#EXTINF:8.5,
segment3.ts
#EXT-X-ENDLIST
M3U8 files start with #EXTM3U and contain a series of tags beginning with #EXT. Below are some of the most common tags:
#EXTM3U: M3U8 file start marker — must be on the first line#EXT-X-VERSION: Specifies the HLS protocol version number#EXTINF: Specifies the duration (in seconds) of the next segment; optional title follows the comma#EXT-X-TARGETDURATION: Specifies the maximum duration of all segments#EXT-X-MEDIA-SEQUENCE: Sequence number of the first segment#EXT-X-STREAM-INF: In master playlists, specifies sub-stream attributes (bandwidth, resolution, etc.)#EXT-X-KEY: Specifies encryption method and key address (AES-128 encryption)#EXT-X-ENDLIST: Playlist end marker (present for VOD, absent for live streaming)#EXT-X-DISCONTINUITY: Marks encoding parameter changes (e.g., quality switch)#EXT-X-MAP: Specifies the initialization segment (for fMP4-format HLS)There are multiple ways to open and play M3U8 files on desktop computers — choose the right tool based on your needs.
VLC is the most popular open-source player, with native support for M3U8/HLS playback and cross-platform support for Windows, Mac, and Linux.
Steps:
PotPlayer is a very popular player on the Windows platform, with powerful features and M3U8 playback support.
If you need to download or convert M3U8 videos, you can use FFmpeg:
ffmpeg -i "https://example.com/stream.m3u8" -c copy output.mp4
There are also many players that support the M3U8 format on mobile devices.
iPhones and iPads have native HLS playback support in the Safari browser — simply open the M3U8 link directly in the browser. You can also use the following apps:
For the Android platform, the following players are recommended:
Playing M3U8 videos on web pages is one of the most common requirements. Since only Safari natively supports HLS, other browsers need to use JavaScript libraries to implement playback.
HLS.js is the most popular open-source HLS playback library, supporting all browsers with MSE support.
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<video id="video" controls></video>
<script>
const video = document.getElementById('video');
const hls = new Hls();
hls.loadSource('https://example.com/stream.m3u8');
hls.attachMedia(video);
</script>
If you don't want to write code, you can directly use an online M3U8 player, such as our M3U8 Online Player — just paste the link to play, with additional features like screenshots and playback speed control.
If you use the video.js player framework, you can pair it with the videojs-contrib-hls plugin to implement HLS playback.
M3U8 is a text playlist file that does not contain actual video data; MP4 is a video container format that contains complete audio and video data. M3U8 is suitable for streaming media playback, while MP4 is suitable for local storage and sharing.
You can use the FFmpeg command-line tool, or use our M3U8 to MP4 Online Tool to convert without downloading any software.
Common causes include: expired links, CORS restrictions, encrypted videos requiring decryption keys, network issues, unsupported players, etc. You can first test whether the link is valid using VLC.
As the core format of HLS streaming technology, M3U8 has become the de facto standard in the online video field. Understanding the format structure and working principles of M3U8 is extremely helpful for video development, video downloading, live streaming playback, and other scenarios.
Whether you are an ordinary user or a developer, mastering the methods for opening and playing M3U8 files will give you more flexibility in handling online videos. If you need to quickly play M3U8 videos, try our M3U8 Online Player.
More great articles and useful tools
Master the core technology of HLS streaming media playback, including complete code examples and solutions to common issues.
Read More →Detailed introduction to 4 FFmpeg methods for merging TS files, comparing the advantages, disadvantages, and use cases of each method.
Read More →Comprehensive coverage of PC, mobile, and web platforms — recommending solutions like VLC, PotPlayer, and web-based online players.
Read More →Use our free M3U8 Online Player — paste the link to play, with speed control, screenshots, and loop playback
Try It Now ➡