If we compare a complete video to a comic book split into many pages, then M3U8 is the "table of contents" of this comic: it clearly marks the page number, number of pages (duration) and storage location (file path/URL) of each page (video segment).
Essentially, M3U8 is a UTF-8 encoded plain text file, and its core content can be understood at a glance. Its most prominent feature is that it must start with the #EXTM3U identifier. An example of the simplest available M3U8 list is as follows:
#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXTINF:9.5, video_001.ts #EXTINF:9.8, video_002.ts #EXT-X-ENDLIST
You will often see these tags in the list:
- #EXT-X-VERSION: List version number, different versions support different functions;
- #EXT-X-TARGETDURATION: The target duration of the segment (in seconds), the player will prepare the buffer according to this standard;
- #EXTINF: The specific duration of the segment follows, and the next line is the file name or URL;
- #EXT-X-ENDLIST: Indicates video on demand (with an end), and the live streaming list usually does not contain it.
It is worth noting that when a video provides multiple resolutions/bitrates, there will be a two-level structure of "master list" and "media list". Through the #EXT-X-STREAM-INF tag, the master list points to multiple "media lists", each representing a resolution, allowing the player to switch according to network conditions.
Summary: M3U8 is not a "video container" but an "index and instruction manual".