Understanding Structure of Correct M3U8 Playlists
M3U8 playlists are commonly used for streaming audio and video content on the internet. They are text files that contain a list of media files to be played in a specific order. In this article, we will discuss the structure of correct M3U8 playlists, focusing on series and single file playlists.
Series Playlists
Series playlists are used when you have multiple files that belong to the same series. For example, you might have a series of videos with names like "series1\_ep1.mp4", "series1\_ep2.mp4", and so on. To create a series playlist, you would create a text file with the extension ".m3u8" and add the following lines:
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXTINF:10,
series1_ep1.mp4
#EXTINF:10,
series1_ep2.mp4
...
The first line, "#EXTM3U", indicates that this is an M3U playlist. The second line, "#EXT-X-MEDIA-SEQUENCE:0", specifies the sequence number of the first media file in the playlist. The "#EXT-X-ALLOW-CACHE:YES" line allows the player to cache the media files for faster playback. The "#EXTINF" line specifies the duration of the media file in seconds, followed by the name of the media file.
Single File Playlists
Single file playlists are used when you have a single media file that you want to play. For example, you might have a video file named "movie.mp4" that you want to play. To create a single file playlist, you would create a text file with the extension ".m3u8" and add the following lines:
#EXTM3U
#EXTINF:120,
movie.mp4
The first line, "#EXTM3U", indicates that this is an M3U playlist. The second line, "#EXTINF:120", specifies the duration of the media file in seconds. The third line specifies the name of the media file.
Subtitles
M3U8 playlists can also include subtitles. To include subtitles, you would add the following lines to the playlist:
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles",LANGUAGE="eng",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="subtitles.eng.vtt"
The "#EXT-X-MEDIA" line specifies the type of media as subtitles, the group ID, the language, the name, and whether it is the default subtitle. The "URI" line specifies the location of the subtitle file.
In this article, we have discussed the structure of correct M3U8 playlists, focusing on series and single file playlists. We have also discussed how to include subtitles in M3U8 playlists. By following the guidelines outlined in this article, you can create M3U8 playlists that are compatible with most media players.
References
- Apple Inc. (2021). HTTP Live Streaming. https://developer.apple.com/documentation/http_live_streaming
- DASH Industry Forum. (2021). Dynamic Adaptive Streaming over HTTP (DASH). https://dashif.org/
- ISO/IEC JTC 1/SC 29/WG 11. (2014). Information technology -- Coding of audio-visual objects -- Part 12: ISO base media file format. https://www.iso.org/standard/67064.html