How to Create an M3U8 Playlist for HLS Streaming
Creating a Simple M3U8 Playlist Manually
You can create a basic VOD playlist in 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 as .m3u8 and serve it with the correct MIME type (e.g. application/vnd.apple.mpegurl). Test with our player.
Using FFmpeg to Generate HLS Playlists
FFmpeg can create playlists and segments automatically:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f hls -hls_time 10 -hls_playlist_type vod playlist.m3u8
This produces a media playlist plus .ts segments. For multi-bitrate masters, use filter_complex / var_stream_map (see FFmpeg HLS docs) or our FFmpeg guide for related commands.
Master Playlist With Multiple Variants
Adaptive streaming 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
Each line after STREAM-INF points to a media playlist for that quality.
Best Practices
- Prefer absolute URLs in production to avoid broken relative paths.
- Include CODECS on STREAM-INF for player compatibility.
- Keep segment durations consistent across variants.
- Validate playlists and test in more than one player.
- Use UTF-8 encoding (true M3U8).
Serving the Playlist
Host the .m3u8 and segments on HTTP(S) with CORS if players load cross-origin. Wrong Content-Type or missing CORS is a common failure — see CORS fix. Structure details: format explained.
Frequently Asked Questions
Can I create M3U8 without FFmpeg?
Yes — write a simple playlist by hand if you already have segments.
What MIME type should I use?application/vnd.apple.mpegurl or application/x-mpegURL.
Do I need a master playlist?
Only for multiple quality variants.
How do I test my playlist?
Open it in our online player.