ByteScope

Ogg file format

Ogg container, commonly wrapping Vorbis/Opus audio or Theora video.

MIME type
application/ogg
Extensions
.ogg, .oga, .ogv
Category
Audio

Magic-number signature

0x000000004F676753OggS'OggS' page capture pattern

About the Ogg format

Ogg is an open, patent-free streaming container most often carrying Vorbis or Opus audio, widely used in games and open-source software. Every page starts with the capture pattern 'OggS'. That word 'every' is the whole design: an Ogg file is not a header followed by data, it is a chain of self-describing pages, each with its own checksum, sequence number and stream serial, so a decoder can join a live stream mid-flight and a damaged download can be resynchronised by scanning forward for the next 4F 67 67 53. The container itself says nothing about the codec — that is decided by the first packet on the first page.

Header layout, byte by byte

OffsetLengthFieldMeaning
04Capture pattern 'OggS'4F 67 67 53. It marks the start of a page, not the start of the file, so a one-second audio clip already contains dozens of them; a hex editor searching for it finds every page boundary in the stream.
41Stream structure versionAlways 0. No second version of the Ogg framing has ever been defined, so anything else here means the bytes are not really an Ogg page.
51Header type flagBit 0 marks a page whose first packet is continued from the previous page, bit 1 marks the beginning of the logical stream and bit 2 the end of it. The very first page of a file therefore reads 02.
68Granule positionA little-endian signed 64-bit position whose meaning is defined by the codec, not by Ogg — a PCM sample count for Vorbis, a count of 48 kHz samples for Opus. All bits set (-1) means no packet finishes on this page, so there is no new position to report.
144Bitstream serial numberA little-endian random-ish id identifying the logical stream this page belongs to. A file carrying video and audio interleaves pages with different serials, and a chained file has one serial per section.
184Page sequence numberLittle-endian, counting from 0 within each logical stream. A jump in this number is exactly how a decoder knows a page was dropped rather than the data being corrupt.
224Page checksumA CRC-32 over the entire page with this field temporarily zeroed, using polynomial 0x04C11DB7 with no input or output reflection and no final XOR — deliberately not the same CRC-32 that ZIP and gzip use, so the two cannot be confused.
261Number of page segmentsHow many entries the segment table has, 0 to 255. It caps a page at 27 + 255 + 255 x 255 = 65307 bytes, which is why Ogg latency is bounded no matter what the codec does.
27variableSegment tableOne byte per segment, each 0-255. A packet's length is the running sum until a value below 255 terminates it, so a value of exactly 255 always means 'continues'. This is where every hand-written Ogg parser goes wrong.
variablevariableFirst packet — the codec identification headerImmediately after the segment table, so offset 28 on a first page with one segment. Vorbis writes 01 followed by 'vorbis', Opus writes 'OpusHead', FLAC-in-Ogg writes 7F followed by 'FLAC', and Theora writes 80 followed by 'theora'. This, not the file extension, is what the audio actually is.

Telling it apart from its neighbours

Easily confused withHow to tell
oga/ogv/opusThere is nothing to distinguish at container level: all four extensions are the same 'OggS' framing, and the convention is only that .oga is audio, .ogv video and .opus an Opus stream. The answer is always the identification packet after the segment table — 01 'vorbis' at offset 28 in a plain Vorbis file, 'OpusHead' at offset 28 in an Opus one. Renaming the file changes nothing, and neither does trusting the MIME type.
FLACFLAC exists in two skins and they are easy to confuse. Native FLAC starts 66 4C 61 43 at offset 0 and goes straight into a 34-byte STREAMINFO block. FLAC inside Ogg starts 4F 67 67 53 like anything else, and the marker 7F 46 4C 41 43 appears at offset 28, followed by a mapping version, a header-packet count, and only then the native 'fLaC' marker and its STREAMINFO.
WebMThe other patent-free open container, and the usual alternative when people ask which one to use. WebM and Matroska are EBML documents beginning 1A 45 DF A3, which shares no bytes at all with 'OggS'. WebM won in browsers for video; Ogg kept Vorbis and Opus.
MP3MP3 is a bare frame stream with no container, beginning with an 'ID3' tag or a frame sync of eleven set bits. It has no page checksums, no sequence numbers and no way to signal a lost frame, which is precisely the gap Ogg was designed to fill for streaming.

How these files break

  • A dropped page in a live stream. Ogg treats this as normal rather than fatal: the sequence number at offset 18 jumps, the decoder reports a gap, and playback resumes at the next capture pattern. A partially corrupt download recovers the same way, by scanning forward for 4F 67 67 53 and picking up from there.
  • Truncation with no end-of-stream page. Because the last page never gets bit 2 of its header type flag set, nothing states the final granule position, so the total duration is unknown. The audio plays to the end of what arrived while the seek bar and the reported length stay wrong.
  • Bit rot inside a page body. The page checksum at offset 22 fails and a decoder discards that whole page — a fraction of a second of audio — instead of the file. The damage is audible as a click, and every later page still verifies.
  • Naive concatenation. Joining two Ogg files with `cat` produces a legal chained stream with two different serial numbers, but a great many players stop at the first end-of-stream page and report the length of the first file only. Remuxing rather than concatenating is the fix.
  • Prepended bytes. An HTTP error body or an ID3 tag glued on the front pushes the first capture pattern off offset 0. Every page is intact and a resynchronising player still finds them, but a detector that only reads offset 0 reports the file as unknown.

Where the format stands today

Ogg's job today is narrower than it once was but very secure. Vorbis was the free answer to MP3 and is still what a huge number of games and open-source applications ship their audio in, because it was unencumbered when MP3 was not. Opus, standardised in RFC 6716 and carried in Ogg for files and in RTP for calls, is now the default voice codec of WebRTC and the best general-purpose low-latency audio codec there is, so Ogg came out of the codec wars with the winner inside it. For video the container lost decisively to WebM and MP4, and .ogv is effectively historical. What keeps Ogg first choice is streaming that has to survive loss: pages are self-describing, checksummed and resynchronisable, so a decoder can join a live stream mid-flight and recover from a dropped packet without any out-of-band signalling.

Open Ogg files on this site

Every one of these runs in your browser — the file never leaves your machine.

Related formats

Formats that are easy to confuse with Ogg — compare their leading bytes.

FormatFirst bytesExtension
MP349 44 33.mp3
FLAC66 4C 61 43.flac
WebM1A 45 DF A3.webm

Frequently asked questions

What is a magic number in a file?

The first few bytes of a file, which identify its format regardless of what the name says. A PNG always starts with 89 50 4E 47; a ZIP with 50 4B 03 04. Operating systems, browsers and the file command all read these bytes rather than trusting the extension, which is why renaming a file does not change what it actually is.

How do I check a file's magic number myself?

On macOS or Linux, xxd -l 16 yourfile prints the first 16 bytes; on Windows, Format-Hex -Path yourfile -Count 16 in PowerShell. Or drop the file into the File Type Identifier on this site, which reads the bytes locally and names the format for you — nothing is uploaded.

Why do two formats share the same magic number?

Because one is built on the other. Every docx, xlsx, pptx, apk, jar and epub begins with the ZIP signature, since all of them are ZIP archives underneath; telling them apart means looking at the entries inside. Java class files and macOS universal binaries both start with CA FE BA BE and are distinguished by the field that follows.

Can a file have no magic number at all?

Yes. Text-based formats — XML, HTML, JSON, SVG, CSV — have no fixed byte signature, so they are recognized structurally instead: a leading <?xml declaration, a <svg element, or a { followed by a quoted key. That detection is a good guess rather than a certainty, which is why this reference marks those formats as probe-detected.

Does a matching magic number mean the file is safe?

No. It tells you what the format is, not whether the contents are harmless — a genuine PDF or docx can still carry a malicious payload. Identifying the true type is a useful first check, especially when the extension disagrees with the bytes, but it is not a malware scan.

Have a file that might be in the Ogg format? Identify it with the File Type Identifier — it reads the magic number locally, nothing is uploaded. Or browse all formats.