Apple Lossless Audio Codec file
audio/mp4
Magic Bytes
Offset: 4
66 74 79 70 4D 34 41 20
The M4A file format is an MPEG-4 audio container developed by Apple Inc. specifically for storing audio data distinct from video-centric MP4 files. It typically encapsulates audio streams encoded with either Advanced Audio Coding (AAC) or the Apple Lossless Audio Codec (ALAC) for high-fidelity playback. While functionally similar to standard MP4 containers, this format is widely supported across Apple devices and modern media players, presenting minimal security risks when obtained from reputable sources.
Validation Code
How to validate .m4a files in Python
Python
def is_m4a(file_path: str) -> bool:
"""
Check if file is a valid M4A by magic bytes.
Signature offset: 4 bytes
"""
signature = bytes([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20])
with open(file_path, "rb") as f:
f.seek(4)
return f.read(8) == signature
How to validate .m4a files in Node.js
Node.js
function isM4A(buffer: Buffer): boolean {
// Signature offset: 4 bytes
const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20]);
if (buffer.length < 12) return false;
return buffer.subarray(4, 12).equals(signature);
}
Go
func IsM4A(data []byte) bool {
// Signature offset: 4 bytes
signature := []byte{0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20}
if len(data) < 12 {
return false
}
return bytes.Equal(data[4:12], signature)
}
API Endpoint
GET
/api/v1/m4a
curl https://filesignature.org/api/v1/m4a