Limited Time Free!  Sign up for 14-day trial plan (no credit card needed) with WAF and Bot Management!
Get Started Now 

What is M3U8 and What is M3U Playlist? How to Open and Convert It?

EdgeOne-Dev Team
Oct 24, 2024

What is M3U8 and What is M3U Playlist? How to Open and Convert It?
What is M3U8 and What is M3U Playlist? How to Open and Convert It?

M3U8, as a common video format, is widely used in online video playback, live streaming, and other streaming media services. Compared to traditional video formats like MP4, M3U8 brings more efficient video transmission, flexible adaptation, and enhanced content protection.  If you are looking to transcode, distribute, and host M3U8 videos, you might want to consider our services.

The M3U (Moving Picture Experts Group Audio Layer 3 Uniform Resource Locator) file format is not essentially an audio or video file. It cannot read network resource audio or video in offline mode. It is a playlist file for audio and video files and is a plain text file. 

The Unicode version of M3U is M3U8, which uses UTF-8-encoded characters. M3U8 files are the basis for the HTTP Live Streaming (HLS) format originally developed by Apple to stream video and radio to iOS devices, and which is now a popular format for adaptive streaming in general.

The specific calculations and explanations are detailed in the M3U8 section of the English version of Wikipedia. As we can see, the m3u8 file is a part of the HTTP Live Streaming (HLS) protocol.

What is HLS?

HTTP Live Streaming, HLS, Media Encoding, Stream Segmenter, MPEG-2 Transport Stream, Origin Web Server, Index File, Client, Audio/Video Inputs
HTTP Live Streaming, HLS, Media Encoding, Stream Segmenter, MPEG-2 Transport Stream, Origin Web Server, Index File, Client, Audio/Video Inputs

HLS is a media streaming protocol based on HTTP developed by Apple Inc. It was primarily designed to address the issues of transmitting and playing online video streams.

Compared to traditional streaming media technologies such as RTSP protocol (there are three types of streaming media protocols: RTMP, RTSP, and HTTP Live Streaming), HLS has the advantage that once the segmentation is completed, no additional specialized software is required for distribution, and a regular web server can be used, which reduces the technical requirements for servers. For widely used CDN services, it greatly reduces the configuration requirements of CDN edge servers and can use any existing CDN.

For non-real-time video, if you want to jump in a long video using a single MP4 format video file and the HTTP protocol, you need a proxy server that supports HTTP range requests to obtain a part of the large file. Not all proxy servers support this well. HTTP Live Streaming only needs to download the corresponding TS segment based on the timeline in the m3u playlist file, without HTTP range requests, which requires less of a proxy server because all proxy servers support efficient caching of small files.

In addition, using TS for streaming media packaging has another advantage, which is that there is no need to load the index before playing, greatly reducing the initial loading delay and improving the user experience.

Furthermore, the biggest advantage of HTTP Live Streaming is adaptive bitrate streaming. The client automatically selects video streams of different bitrates based on the network conditions, using high bitrates when conditions permit and low bitrates when the network is busy, and automatically switches between the two. This is very helpful for ensuring smooth playback in unstable mobile device network conditions.

What is the M3U8 and M3U Playlist?

The m3u8 file is essentially a m3u playlist, which can be a media playlist or a master playlist. However, regardless of the type of playlist, the text used inside is encoded in UTF-8.

When the m3u8 file is used as a media playlist, it records a series of media segment resources that can be played in sequence to display the complete multimedia resource. Its format is as follows:

#EXTM3U
#EXT-X-TARGETDURATION:10

#EXTINF:9.009,
http://media.example.com/first.ts
#EXTINF:9.009,
http://media.example.com/second.ts
#EXTINF:3.003,
http://media.example.com/third.ts

For on-demand playback, the client only needs to download the segment resources in order and play them one by one. However, for live streaming, the client needs to periodically request the m3u8 file to check if there are new segment data that need to be downloaded and played.

When the m3u8 file is used as a master playlist, it provides a list of variant streams for the same media resource. Its format is as follows:

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2"
http://example.com/low/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2"
http://example.com/lo_mid/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2"
http://example.com/hi_mid/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=640000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
http://example.com/high/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=64000,CODECS="mp4a.40.5"
http://example.com/audio/index.m3u8

The variant stream resources specify multiple media playlists with different bitrates and formats. Additionally, the variant stream resources can also provide different versions of the content, such as audio files in different languages or video files shot from different angles. Clients can select the appropriate bitrate resources based on different network conditions, and it is recommended to select the appropriate content based on user preferences.

To learn more about the m3u playlist and the HLS protocol, you can refer to the following links:

HLS.js Documentation

Creating a Master Playlist

Adding Alternate Media to a Playlist

M3U8 File Format

The m3u8 file format mainly includes three aspects:

M3U Playlist

The content of the m3u playlist (m3u8 file) must strictly comply with the requirements of the defined specification. The following are some of the main conditions that need to be followed: 

  • The m3u8 file must be encoded in UTF-8 and cannot use Byte Order Mark (BOM) byte order. It cannot contain utf-8 control characters (U+0000 ~ U_001F and U+007F ~ u+009F). 
  • Each line of the m3u8 file must be either a URI, an empty line, or a string starting with #. No white-space characters are allowed except for explicitly declared elements. 
  • Strings starting with # in the m3u8 file are either comments or tags. Tags start with #EXT and are case-sensitive.

Attribute Lists

Some specific tags have values in the form of attribute lists. The attribute list following the tag is separated into multiple sets of attribute/value pairs without spaces, using a comma as the separator.

The syntax format of the attribute/value pair is as follows:

AttributeName=AttributeValue

The AttributeName is an unquoted string composed of [A..Z], [0..9], and -. Therefore, AttributeName can only use uppercase letters and cannot use lowercase letters. There should be no spaces between AttributeName and =, and similarly, there should be no spaces between = and AttributeValue.

Tags

Tags are used to specify the global parameters of the m3u8 file or some information about the segment files/media playlists that follow it.

Tags can be divided into five types: Basic Tags, Media Segment Tags, Media Playlist Tags, Master Playlist Tags, and Playlist Tags. Their specific contents are shown below:

  1. Basic Tags:
  • #EXTM3U
  • #EXT-X-VERSION
  • #EXT-X-ALLOW-CACHE
  • #EXT-X-MEDIA-SEQUENCE
  • #EXT-X-TARGETDURATION
  1. Media Segment Tags:
  • #EXTINF
  • #EXT-X-BYTERANGE
  • #EXT-X-DISCONTINUITY
  • #EXT-X-KEY
  • #EXT-X-MAP
  • #EXT-X-PROGRAM-DATE-TIME
  • #EXT-X-DATERANGE
  1. Media Playlist Tags:
  • #EXT-X-TITLE
  • #EXT-X-PLAYLIST-TYPE
  • #EXT-X-MEDIA
  • #EXT-X-STREAM-INF
  • #EXT-X-I-FRAME-STREAM-INF
  • #EXT-X-ENDLIST
  1. Master Playlist Tags:
  • #EXT-X-MEDIA
  • #EXT-X-STREAM-INF
  • #EXT-X-I-FRAME-STREAM-INF
  • #EXT-X-SESSION-DATA
  • #EXT-X-SESSION-KEY
  1. Playlist Tags:
  • #EXT-X-DISCONTINUITY-SEQUENCE
  • #EXT-X-ENDLIST
  • #EXT-X-INDEPENDENT-SEGMENTS
  • #EXT-X-START
  • #EXT-X-VERSION

How to Open M3U8 Files?

M3U8 files are playlists containing references to media files. They can be opened and played using media players that support the M3U8 format. Here are the steps to open M3U8 files:

We provide a free online M3U8 Player that supports WebRTC, FLV, and HLS live streaming, as well as on-demand playback in HLS, DASH, FLV, and MP4 formats for your convenience. Feel free to use it.

M3U8 files are typically used for streaming media content over the internet. The media files referenced in the playlist may not be stored locally on your computer, but rather on a remote server. Therefore, a stable internet connection is required to play the media files smoothly.

How to Convert M3U8 to Mp4?

M3U8 files are playlists containing references to media files, while MP4 is a video file format. To convert M3U8 to MP4, you need to download the media files referenced in the playlist and then use a video converter to convert them to MP4 format. 

1. Download the media files referenced in the M3U8 playlist. You can use a video downloader tool such as Video DownloadHelper, VLC media player, or IDM (Internet Download Manager) to download the media files.

2. Once the media files are downloaded, use a video converter tool to convert them to MP4 format. There are many video converter tools available online, such as HandBrake, Any Video Converter, and Freemake Video Converter.

3. Open the video converter tool and select the media files you want to convert. Choose the MP4 format as the output format.

4. Customize the video settings such as resolution, bitrate, and frame rate if necessary.

5. Start the conversion process and wait for it to complete.

6. Once the conversion is complete, you will have an MP4 video file that you can play on any media player that supports MP4 format.

Converting M3U8 to MP4 may result in a loss of quality, depending on the video converter tool and settings used.

How to Rewrite M3U8 Files?

Tencent Edge Functions provides a serverless code execution environment for the edge nodes of Tencent EdgeOne. Thanks to the programmable capabilities of EdgeOne edge functions, developers can process M3U8 media files at edge nodes and dynamically modify and inject content. Rewriting and processing M3U8 files can help developers achieve richer and more flexible streaming media application scenarios. Here are some common scenarios:

  1. Customized playlist: Developers may need to choose different media streams based on users' network conditions, device performance, or geographic location.
  2. Content security and access control: To protect copyrighted content, developers may need to process M3U8 files to implement encryption, add access tokens, and other features.
  3. Ad insertion: Inserting ads in streaming media content is a common business model. Developers can modify M3U8 files to insert ad segments at specific times during video playback.

In the blog post "How to Rewrite M3U8 Files?", we introduced how to dynamically modify the content of M3U8 files using Tencent Edge Functions. For a practical example of M3U8 rewriting, access control, and more code implementations, we invite you to explore our GitHub repository.

Conclusion

In conclusion, M3U8 is a powerful and flexible file format for streaming multimedia content. It has become increasingly popular due to its adaptability and ease of use. If you have more extensive needs related to video asset management, such as swift uploading, transcoding, storage, and accelerated playback, EdgeOne VOD is the perfect solution.

Tencent EdgeOne VOD (Video on Demand) offers an extensive suite of features such as cloud video storage, video transcoding, and video playback acceleration, ensuring a quick, flexible, and high-quality video delivery. This allows you to focus on your core business, pick and choose services as per your needs, and swiftly adapt to market changes. We also offer a free trial for you to get started. Click here to begin your journey with us.