Introduction
An .ogg file is usually Vorbis audio inside an Ogg container. Both come
from the Xiph.Org Foundation and are open and royalty-free. Vorbis is a lossy codec in
the same class as MP3 and AAC, and it is common in games and on Linux.
Ogg is a general container, specified in RFC 3533, so an .ogg file can
also hold Opus, FLAC or Speex audio, or Theora video. The reference pages cover the Ogg
page layer, each kind of stream and the comments they all share. Opus has
its own pages.
Extensions and media types
RFC 5334 registers three media types for Ogg, and the extensions that go with them.
Xiph.Org keeps .ogg for Ogg Vorbis audio, the oldest and commonest kind
(it was once used for every Ogg file, so other content still turns up under it):
| Extension | Media type | What it holds |
|---|---|---|
.ogg | audio/ogg | Vorbis audio, by Xiph.Org’s recommendation |
.oga | audio/ogg | any other Ogg audio: FLAC, Speex, Opus, OggPCM, with or without Skeleton |
.opus | audio/ogg | Opus audio (RFC 7845) |
.spx | audio/ogg | Speex audio |
.ogv | video/ogg | video (Theora, Dirac and others), usually with audio |
.ogx | application/ogg | multiplexed Ogg of any other kind, such as several video tracks or an application’s own streams; it should start with a Skeleton stream |
Each media type takes an optional codecs parameter naming the streams inside,
such as audio/ogg; codecs=vorbis, audio/ogg; codecs=opus or
video/ogg; codecs="theora, vorbis", so a player can tell before it opens the file
whether it can play it.
Structure
An Ogg file is a sequence of pages. Each page starts with the capture pattern
OggS, followed by a version byte, header flags (continued packet, first
page, last page), a 64-bit granule position, the stream’s serial number, a page
sequence number, a CRC-32 checksum and a segment table. The segment table gives the
lengths of the pieces that make up the page’s packets.
A Vorbis stream begins with three header packets: identification (channels and sample
rate), comment (tags such as TITLE and ARTIST) and setup
(the codebooks). The audio packets follow. For Vorbis, the granule position counts
sample frames, which lets players seek.
0OggS page identification headervaries…OggS pages comment and setup headersvaries…OggS pages audio packets, last page flaggedrepeated+0Page header OggS, flags, granule, serial, sequence, CRC27 bytes+27Segment table one length byte per segmentvaries…Segments the packet datavaries
Not described
Unknown
- Reference and viewer: the frames of pre-Opus CELT streams
(
CELT). The header is read, but the experimental bit stream changed with nearly every libcelt release and no document describes any of its versions, so the frames are shown as labelled bytes. Opus’s CELT layer, its successor, is fully described.
All the audio codecs Ogg carries (Vorbis, Opus, Speex, FLAC, PCM, and OGM’s MP3, AC-3 and AAC) are decoded. The Ogg layer of the Theora, Dirac, VP8, Kate, Skeleton and other streams is described and shown in full; what their packets contain belongs to those codecs’ own formats, as the scope statement on the other streams page sets out.
Links
Software
- VLC media player – free player for almost any audio or video file (Windows, macOS, Linux, mobile)
- foobar2000 – free music player and converter (Windows, macOS, mobile)
- Audacity – free audio editor that opens and exports Ogg Vorbis (Windows, macOS, Linux)
- MusicBee – free music player and library manager (Windows)
- Vorbis reference tools – the
oggencandoggdeccommand-line encoder and decoder (Windows, macOS, Linux) - FFmpeg – command-line tool that converts Ogg files to and from other formats (Windows, macOS, Linux)
Developers
- libogg – library for reading and writing the Ogg container (C)
- libvorbis – the reference Vorbis encoder and decoder (C)
- stb_vorbis – single-file Ogg Vorbis decoder (C)
- libsndfile – library that reads and writes Ogg Vorbis (C)
Reference
- RFC 3533 – the specification of the Ogg encapsulation format
- RFC 5334 – Ogg media types: audio/ogg, video/ogg and application/ogg, and the codecs parameter
- Vorbis I specification – the Xiph.Org Foundation’s full description of the Vorbis codec