# Ogg

Canonical URL: https://encode.wiki/containers/ogg/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): 0b477115f3fd131ec73ceecbeab82d4bf4bab7507f1afebf28d33490bd92886e

Ogg is Xiph.Org's open container. Today it is mostly used for audio: [Opus](/codecs/audio/opus/) in a `.opus` file is the most common case, followed by [Vorbis](/codecs/audio/vorbis/), [FLAC](/codecs/audio/flac/) and Speex. It can also hold [Theora](/codecs/video/theora/) video, but nobody should start a new video project on that combination.

## Extensions

| Extension | Contents                                                       |
| --------- | -------------------------------------------------------------- |
| `.opus`   | Opus audio in Ogg (the recommended extension for Opus)         |
| `.ogg`    | Historically Vorbis; now ambiguous, can be Opus, FLAC or video |
| `.oga`    | Ogg audio, any codec                                           |
| `.ogv`    | Ogg video, normally Theora + Vorbis                            |
| `.spx`    | Speex                                                          |

The extension does not say which codec is inside; `ffprobe` does.

**Codecs documented for Ogg on this wiki**

| Relationship | Project or format | Evidence and scope | Status |
| --- | --- | --- | --- |
| Carried By by | [Opus](/codecs/audio/opus/) | Ogg Opus uses OpusHead and OpusTags headers with 48 kHz granule-position semantics. Scope: Container Mapping. Sources: [RFC 7845: Ogg Encapsulation for the Opus Audio Codec](https://datatracker.ietf.org/doc/rfc7845/). | Normative |

[Open the complete typed relationship catalog](/api/v1/catalog.json).

## Make Ogg files

```sh
ffmpeg -i input.flac -c:a libopus -b:a 128k output.opus
ffmpeg -i input.flac -c:a libvorbis -q:a 5 output.ogg
ffmpeg -i input.mkv -c:v libtheora -q:v 7 -c:a libvorbis -q:a 5 output.ogv
```

Opus is the better modern choice; see [Opus](/codecs/audio/opus/) for bitrates. Moving an existing Opus stream between Ogg and MP4/MKV is lossless: `ffmpeg -i input.mp4 -c copy output.opus`. Ogg cannot hold AAC, MP3 or H.264 (FFmpeg rejects them), so converting from those means re-encoding.

For standalone Opus encoding, `opusenc` from opus-tools writes Ogg Opus directly and can embed cover art with `--picture`.

## Properties of Ogg

- **Streaming-first design.** Ogg is made of self-contained pages with no global index, so it can be written live and chained (several files concatenated into one stream). Seeking works by bisection, which is fast for audio and sloppy for video.
- **Metadata** is stored as Vorbis-style comments (`ARTIST=`, `TITLE=`…). Opus adds `R128_TRACK_GAIN` and `R128_ALBUM_GAIN` for loudness; players apply the header's output gain and these tags. Edit tags with `opustags`, `vorbiscomment` or `ffmpeg -metadata`.
- **Opus timing.** An Ogg Opus stream always decodes at 48 kHz, whatever the input rate, and carries a pre-skip value the decoder discards so the first sample lines up. That is why `ffprobe` shows `sample_rate=48000` for any `.opus`.
- **Overhead.** Ogg's page structure costs a bit more than MKV or MP4 for the same stream, which is small next to Opus bitrates.

## Support

Ogg Opus and Vorbis play in Chrome, Firefox, VLC, mpv, Android and most Linux and Windows players. Safari added Ogg support for Opus and Vorbis in 18.4 (March 2025, on macOS 15.4, iOS/iPadOS 18.4 and visionOS 2.4); older Apple software cannot play `.opus` files without help. For maximum compatibility, deliver MP4 with AAC, or an Opus-in-MP4/WebM file where the player supports it.
