Question

I'm wondering why Vorbis needs any container at all? I know you can stick Vorbis in an Ogg container or a Matroska container, but if I'm not going to bundle it with any video or any other multimedia why can't the Vorbis data stand alone in its own file?

Has anyone had any experience doing this? I googled before searching SO and I only found a single mention in the oggvorbis mailing list with no details.

Was it helpful?

Solution

It is completely possible. You do not need to know before hand the length of any Vorbis packet (whether they are headers or audio) to be able to decode them. Without the Ogg wrapper (or an alternative wrapper) you will miss out on a few things, but they might not be important for your application:

  • The page checksums - not too important if you are reading from a disk or other rather reliable source
  • The page granule/last sample positions - useful for improving seeking performance, and for specifying

However, you can pretty trivially make a pure Vorbis bytestream from a ogg file (given there is only one Vorbis stream in it) by:

  1. Skipping 26 bytes
  2. n = read 1 byte
  3. countOfBytesToRead = sum of next n bytes
  4. Read countOfBytesToRead bytes into your Vorbis bytestream
  5. Repeat 1-4 until Ogg file is exhausted
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top