An Ogg physical bitstream is made of one or more logical streams, each with its own serial number. Two arrangements combine them, and they can be used together.
Logical streams
Every page carries the serial number of its logical stream. A stream’s first page has the BOS flag set and holds only the first packet of the stream, which identifies the codec. Its last page has the EOS flag set. Page sequence numbers count up by one for each stream separately.
Identifying streams
The first few bytes of a stream’s first packet name its codec:
| Begins with | Stream |
|---|---|
0x01 vorbis | Vorbis |
OpusHead | Opus |
Speex | Speex |
0x7F FLAC | FLAC |
0x80 theora | Theora video |
Further stream types are listed under other streams.
Multiplexing
Several logical streams can share a file, such as a Theora video stream and a Vorbis audio stream. Pages of different streams are mixed in time order, so a reader can play them together while reading once through. All the BOS pages come first, before any page that holds data, and each stream’s header packets come before any audio or video data.
Chaining
Files can also be joined end to end. When every stream of one link has reached EOS, a new group of BOS pages begins a new link. Each link is independent, and the serial numbers must be different from those of the link before it. Concatenating two Ogg files in this way plays them one after the other, with a new set of headers.
In the explorer
The explorer finds every logical stream and link, and shows each stream’s headers, comments and packets on its own.
Links
- RFC 3533 – the Ogg encapsulation format