A Vorbis stream starts with three header packets: identification, comment and setup. Audio packets follow them. Vorbis is defined by the Vorbis I specification, from the Xiph.Org Foundation. The identification packet sits alone on the stream’s BOS page, and the comment and setup packets start on the next page and finish before the first audio page.
Common header
Every Vorbis header packet starts the same way, with numbers little-endian and bit fields filled from the least significant bit up:
| Offset | Size | Name | Values |
|---|---|---|---|
| 0 | 1 | packet_type | 1 identification, 3 comment, 5 setup |
| 1 | 6 | codec name | the ASCII characters vorbis |
Identification header
| Offset | Size | Name | Description |
|---|---|---|---|
| 7 | 4 | vorbis_version | must be 0 |
| 11 | 1 | audio_channels | the channel count; must be above 0 |
| 12 | 4 | audio_sample_rate | the sample rate in Hz; must be above 0 |
| 16 | 4 | bitrate_maximum | upper bound of the bit rate, or 0 when none is stated (signed) |
| 20 | 4 | bitrate_nominal | average bit rate, or 0 when none is stated (signed) |
| 24 | 4 | bitrate_minimum | lower bound of the bit rate, or 0 when none is stated (signed) |
| 28 | 4 bits | blocksize_0 | the low nibble: the short block size is 2 to this power |
| 28 | 4 bits | blocksize_1 | the high nibble: the long block size is 2 to this power |
| 29 | 1 bit | framing_flag | must be 1; the rest of the byte is padding |
Block sizes are powers of two from 64 to 8192, and blocksize_0 must be no
larger than blocksize_1.
Channel order
| Channels | Order |
|---|---|
| 1 | mono |
| 2 | left, right |
| 3 | left, centre, right |
| 4 | front left, front right, rear left, rear right |
| 5 | front left, centre, front right, rear left, rear right |
| 6 | front left, centre, front right, rear left, rear right, LFE |
| 7 | front left, centre, front right, side left, side right, rear centre, LFE |
| 8 | front left, centre, front right, side left, side right, rear left, rear right, LFE |
| 9 or more | no order defined |
Comment header
The comment packet holds the Vorbis comments after the common header. It ends with a framing bit, which must be 1.
Setup header
The third packet holds everything needed to decode audio. See the Vorbis setup header.
Links
- Vorbis I specification – the Xiph.Org Foundation’s description of the codec