[Vorbis-dev] Total uncompressed size

Michael Smith msmith at xiph.org
Thu Sep 1 03:01:35 PDT 2005


On 8/30/05, Tony O'Bryan <TO'Bryan at greenecountymo.org> wrote:
> Is there any place in the Vorbis header information to determine the total
> uncompressed size of PCM data without having to decompress the file?

Not in the header, no. Vorbis was designed to be a streamable format,
and putting this sort of information in the header precludes that.
It's also largely unneccesary.

However, to figure out the total length you certainly don't need to
decode the entire file. You need to read the vorbis headers, and then
seek to the end of the file (if it's a single chain; if you have
multiple logical streams chained together, it's a little more complex
- see the ogg docs if my terminology here is confusing). The
granulepos value of the final ogg page of the stream will give you the
total number of samples in the file, you can then multiply that by the
number of channels (which you got from the header), and by the sample
size you're decoding to (which is your choice, typically you'd pick 16
bit data, which is 2 bytes per channel per sample).

Mike


More information about the Vorbis-dev mailing list