[vorbis] Average Bitrate Calculation

Michael Smith msmith at labyrinth.net.au
Sat Sep 29 19:02:25 PDT 2001

At 01:56 PM 9/30/01 +1200, you wrote:
>Can someone please provide the method of calculating the average bitrate 
>from an OGG file (not using libraries).  I currently have obtained: 
>Channels, Nominal Bitrate, Sample Rate, Total Samples, (Duration).

Find (through seeking) the final page of the logical stream in the file.
Note that because you can have multiple logical streams in a file, you'll
have to do this repeatedly, and it's kinda complex to get right.

Then, take the granulepos value of this final page. This is the number of
samples in the stream. Divide by sample rate to get total number of seconds.
Then use the length (in bytes) of the logical stream (not the entire file)
to get bitrate in the obvious way.

Conceptually simple. In practice, difficult to get all cases correct.
See vorbisfile.c for one way to do it correctly.


--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.

More information about the Vorbis mailing list