OPUS
audio/opus
Magic Bytes
Offset: 0
4F 67 67 53 00 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 4F 70 75 73 48 65 61 64
Opus is a lossy audio coding format developed by the Xiph.Org Foundation and standardized by the Internet Engineering Task Force. It is primarily utilized for low-latency interactive voice communication, high-quality internet streaming, and digital storage within Ogg containers. As a royalty-free open standard that replaces legacy codecs like Vorbis, the format is considered inherently safe because it lacks internal scripting capabilities or executable macro structures.
Validation Code
How to validate .opus files in Python
Python
def is_opus(file_path: str) -> bool:
"""Check if file is a valid OPUS by magic bytes."""
signature = bytes([0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64])
with open(file_path, "rb") as f:
return f.read(36) == signature
How to validate .opus files in Node.js
Node.js
function isOPUS(buffer: Buffer): boolean {
const signature = Buffer.from([0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64]);
return buffer.subarray(0, 36).equals(signature);
}
Go
func IsOPUS(data []byte) bool {
signature := []byte{0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64}
if len(data) < 36 {
return false
}
return bytes.Equal(data[:36], signature)
}
API Endpoint
GET
/api/v1/opus
curl https://filesignature.org/api/v1/opus