M3U8
application/vnd.apple.mpegurl
Magic Bytes
Offset: 0
23 45 58 54 4D 33 55
M3U8 is a UTF-8 encoded multimedia playlist file format developed by Apple Inc. to support the HTTP Live Streaming (HLS) protocol. This format serves as an index file for multimedia streams, directing players to sequential video chunks or audio segments for playback across various networks. Originally derived from the simple M3U format used by Winamp, these plain text files are inherently safe but require compatible players to interpret the specific UTF-8 character encoding correctly.
Validation Code
How to validate .m3u8 files in Python
Python
def is_m3u8(file_path: str) -> bool:
"""Check if file is a valid M3U8 by magic bytes."""
signature = bytes([0x23, 0x45, 0x58, 0x54, 0x4D, 0x33, 0x55])
with open(file_path, "rb") as f:
return f.read(7) == signature
How to validate .m3u8 files in Node.js
Node.js
function isM3U8(buffer: Buffer): boolean {
const signature = Buffer.from([0x23, 0x45, 0x58, 0x54, 0x4D, 0x33, 0x55]);
return buffer.subarray(0, 7).equals(signature);
}
Go
func IsM3U8(data []byte) bool {
signature := []byte{0x23, 0x45, 0x58, 0x54, 0x4D, 0x33, 0x55}
if len(data) < 7 {
return false
}
return bytes.Equal(data[:7], signature)
}
API Endpoint
GET
/api/v1/m3u8
curl https://filesignature.org/api/v1/m3u8