MPEG-4 video|QuickTime file
video/mp4
Magic Bytes
Offset: 4
66 74 79 70 4D 34 56 20
The M4V file format is a multimedia container developed by Apple Inc., derived directly from the MPEG-4 Part 14 standard. It is primarily utilized for distributing video content, such as movies and television episodes, within the iTunes Store ecosystem. Although structurally identical to MP4 files when unprotected, M4V containers frequently incorporate Apple’s FairPlay DRM copy protection to restrict playback to authorized computers and Apple devices.
Validation Code
How to validate .m4v files in Python
Python
def is_m4v(file_path: str) -> bool:
"""
Check if file is a valid M4V by magic bytes.
Signature offset: 4 bytes
"""
signature = bytes([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56, 0x20])
with open(file_path, "rb") as f:
f.seek(4)
return f.read(8) == signature
How to validate .m4v files in Node.js
Node.js
function isM4V(buffer: Buffer): boolean {
// Signature offset: 4 bytes
const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56, 0x20]);
if (buffer.length < 12) return false;
return buffer.subarray(4, 12).equals(signature);
}
Go
func IsM4V(data []byte) bool {
// Signature offset: 4 bytes
signature := []byte{0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56, 0x20}
if len(data) < 12 {
return false
}
return bytes.Equal(data[4:12], signature)
}
API Endpoint
GET
/api/v1/m4v
curl https://filesignature.org/api/v1/m4v