2026-07-035 min readcreate m3u8 playlist, make m3u8 file, generate m3u8 playlist

How to Create an M3U8 Playlist for HLS Streaming

Step-by-step guide to creating M3U8 playlists. Learn to write master and media playlists manually or generate them with FFmpeg.

Creating a Simple M3U8 Playlist Manually

You can create a basic M3U8 playlist with any text editor:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXTINF:10.000,
https://example.com/video/segment-001.ts
#EXTINF:10.000,
https://example.com/video/segment-002.ts
#EXTINF:10.000,
https://example.com/video/segment-003.ts
#EXT-X-ENDLIST

Save the file with a .m3u8 extension and serve it from a web server with the correct MIME type.

Using FFmpeg to Generate HLS Playlists

FFmpeg can automatically create M3U8 playlists:

# Single quality level
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f hls -hls_time 10 -hls_playlist_type vod playlist.m3u8

# Multiple quality levels (adaptive)
ffmpeg -i input.mp4 -filter_complex "[0:v]split=3[v1][v2][v3];[v1]scale=-2:360[v1out];[v2]scale=-2:720[v2out];[v3]scale=-2:1080[v3out]" -map [v1out] -map [v2out] -map [v3out] -map 0:a -c:v libx264 -c:a aac -f hls -var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2" master.m3u8

Master Playlist with Multiple Variants

A proper adaptive streaming setup needs a master playlist:

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360,CODECS="avc1.42e01e,mp4a.40.2"
360p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2"
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2"
1080p.m3u8

Best Practices

  • Always use absolute URLs for production streams to avoid broken paths
  • Include CODECS parameter in #EXT-X-STREAM-INF for player compatibility
  • Use consistent segment durations across all variants
  • Validate playlists with Apple's HLS validator tool or online validators
  • Test with multiple players, including our M3U8 player

Related Articles