Ogg

Also known as: Ogg container · OGV

On this page 7

Ogg is a free, open container format maintained by the Xiph.Org Foundation that multiplexes compressed audio, video and metadata into a single page-based bitstream. In video, Ogg files usually carry Theora video with Vorbis or Opus audio and use the .ogv extension, while audio-only files use .ogg, .oga or .opus.

Within containers & formats, Ogg stands out as a patent-free, streaming-oriented design specified in RFC 3533. It played a major role in early open web video, although WebM and MP4 have since replaced it in most video workflows.

How the Ogg page structure works

An Ogg stream is a sequence of pages, each beginning with the four-byte capture pattern OggS. A page holds a header and up to 255 segments of up to 255 bytes, so a single page can carry at most about 64 KB of payload. Codec packets are split into segments with a scheme called lacing, and a packet larger than one page continues across several pages.

Because every page starts with a recognizable pattern and ends with a CRC32 checksum, a decoder can resynchronize after data loss or start reading in the middle of a stream. This property made Ogg attractive for internet radio and live streaming, where a listener may join at any moment.

The table below lists the main fields of an Ogg page header and their purpose.

FieldSizePurpose
Capture pattern4 bytesMarks the start of a page with OggS
Header type flags1 byteSignal continuation, first page or last page
Granule position8 bytesCodec-specific time or sample position
Bitstream serial number4 bytesIdentifies the logical stream
Page sequence number4 bytesDetects lost or reordered pages
CRC checksum4 bytesVerifies page integrity
Segment table1 to 255 bytesLists lacing values for the payload
Fields in the Ogg page header

Logical bitstreams, multiplexing and the granule position

Each elementary stream inside an Ogg file is a logical bitstream with its own serial number. Ogg combines them in two ways: grouping interleaves pages of concurrent streams, such as video and audio, and chaining places complete streams one after another, which suits playlists or radio programs with changing metadata.

The granule position is the key timing field, but Ogg itself does not define its meaning. Each codec interprets it: for Vorbis and Opus it counts audio samples, while for Theora it encodes the last keyframe and the frame offset since that keyframe. This codec-dependent design keeps the container simple but forces demuxers to understand every codec they handle.

The following table shows the codecs most often found in Ogg and the role each one plays.

CodecTypeTypical extensionStatus
TheoraLossy video.ogvLegacy, no longer developed
VorbisLossy audio.ogg or .ogaMature and widely supported
OpusLossy audio.opusCurrent recommended audio codec
FLACLossless audio.ogaCommon for archival audio
SpeexSpeech audio.spxSuperseded by Opus
SkeletonMetadata streamInside .ogvOptional index and stream data
Common codecs carried in Ogg

Ogg compared with other container formats

Ogg differs from MP4 and MKV mainly in its lack of a mandatory global index. MP4 stores a moov atom that tells a player exactly where every sample lives, and MKV uses cues for the same job. A basic Ogg file must be searched by bisection to seek, which is slower over a network, although the optional Skeleton stream can add an index.

The comparison below places Ogg among its closest neighbors in the containers & formats Topic.

ContainerLicensingSeeking methodTypical video codecs
OggRoyalty-free, openBisection or Skeleton indexTheora
WebMRoyalty-free, openCues indexVP8, VP9, AV1
MKVOpen specificationCues indexAlmost any codec
MP4ISO standardMoov atom sample tablesH.264, H.265, AV1
MPEG-TSISO standardPacket scanningMPEG-2, H.264
Ogg and related containers

WebM is in practice the successor of Ogg video on the web. It keeps the royalty-free goal but uses a Matroska-based structure and the more efficient VP8, VP9 and AV1 codecs, which outperform Theora at the same bitrate.

Practical use of Ogg today

Ogg remains highly relevant for audio and only marginally relevant for video. Opus and Vorbis in Ogg are standard in games, voice applications, open-source software and some streaming services, while .ogv video persists mainly in legacy archives and open-content repositories.

The decision table below shows when Ogg is a reasonable choice and when another container fits better.

Use caseRecommendationReason
Game sound effects and musicOgg Vorbis or Ogg OpusFree, compact, widely supported by engines
Internet radio streamOgg OpusResynchronization and chaining support
New web videoWebM or MP4 insteadBetter codecs and broader playback
Lossless audio archiveFLAC in Ogg or native FLACOpen format without patent risk
Professional video editingAvoid OggWeak support in editing software
Choosing Ogg by use case

Limitations and common misconceptions

The most frequent misconception is that Ogg is an audio codec. Ogg is only the container; Vorbis or Opus is the codec inside. A file named .ogg can therefore contain different audio formats, which is why Xiph.Org later recommended specific extensions and MIME types in RFC 5334.

  • Slow seeking over networks: files without a Skeleton index require several range requests to find a position.
  • Limited video codec choice: Theora is the only widely used video codec in Ogg, and it is no longer developed.
  • Weak professional support: most editing applications and broadcast systems do not import Ogg video.
  • Fragile timing logic: because granule positions are codec-specific, unusual codec combinations can confuse demuxers.

In simple terms

Ogg is a free digital envelope for sound and video. The envelope does not decide how the picture or sound is compressed; it simply holds those pieces together, keeps them in sync and lets a player read them in order.

Its special trait is that it cuts the content into small labeled pages, a bit like numbered sheets in a binder. If a few sheets go missing during an internet stream, the player finds the next sheet and keeps playing. Today Ogg is mainly used for audio, while newer envelopes such as WebM and MP4 have taken over most video.

A practical example

An independent game studio needs about 400 sound effects and 30 music tracks for a cross-platform game. Uncompressed WAV files would take roughly 2 GB, which is too much for a downloadable title, and the studio wants to avoid any codec licensing fees.

The audio lead encodes the music as Ogg Vorbis at about 160 kbit/s and the short effects as Ogg Opus. The game engine decodes both natively on Windows, Linux and consoles. Total audio size drops to roughly 180 MB, with no audible difference for players in blind listening tests run by the team.

For the trailer on the studio website, however, the team does not use Ogg video. They export WebM with VP9 and MP4 with H.264, because those containers play in every modern browser. The outcome shows the typical split: Ogg for audio, other containers for video.