1

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.

Charles
  • 48,924
  • 13
  • 96
  • 136
  • There's nothing stopping you, but you might have to write your own decoder binary. It's like asking if you can use raw compressed gzip data without the headers and various fields if you know ahead of time what they're going to be hard-coded to. Technically yes, and you might end up with data files that are a few bytes smaller, but for the sake of not having to reinvent the wheel, it's generally a lot easier not to. – King Skippus Jun 05 '12 at 02:25
  • 2
    I'm actually not asking this with the intent of saving disk space. I'm asking because I'm going to have to write my own decoder for audio (due to licensing reasons) and it seems like the added complexity of dealing with the ogg wrapper isn't worth it. –  Jun 05 '12 at 14:10

1 Answers1

1

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
sh54
  • 1,080
  • 1
  • 10
  • 20