Ogg Vorbis Codec compressed Multimedia file
audio/ogg
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 01 76 6F 72 62 69 73
The Ogg Vorbis format is an open-source, patent-free audio compression standard developed and maintained by the Xiph.Org Foundation. It is widely utilized for lossy audio streaming, video game sound effects, and digital music distribution because of its efficient variable bitrate encoding. As a safe multimedia format, it provides a royalty-free alternative to proprietary codecs, though it is now often superseded by the more advanced Opus codec for modern web-based audio.
Validation Code
How to validate .ogg files in Python
Python
def is_ogg(file_path: str) -> bool:
"""Check if file is a valid OGG 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, 0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73])
with open(file_path, "rb") as f:
return f.read(35) == signature
How to validate .ogg files in Node.js
Node.js
function isOGG(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, 0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73]);
return buffer.subarray(0, 35).equals(signature);
}
Go
func IsOGG(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, 0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73}
if len(data) < 35 {
return false
}
return bytes.Equal(data[:35], signature)
}
API Endpoint
GET
/api/v1/ogg
curl https://filesignature.org/api/v1/ogg