At 11:03 PM 6/9/01 -0700, you wrote:>
>Hello,
>
> First off, congratulations on the studious work with
>Ogg Vorbis. I have just a short question. I'm working on a project that
>would like to quickly gather some information about a file encoded with
>ogg vorbis. Specifically, the average bitrate and the length of the
>stream as a function of seconds. I've read, I think, that there is an
>average bitrate stored in the stream someplace, however, do I
>need to use the functionality of libogg in order to locate it? Or is
>there some 'magic' position in the file I can seek to and read
>an integer quantity for this information.
There are minimum, maximum, and average bitrates stored in the file, and
they exist at fixed offsets from the start of the stream. However, these
are inaccurate, and shouldn't be used for calculating average bitrate or
file length. Instead, you have to look at the last page in the bitstream
and take the granulepos value on that page to find the stream length (in
samples). Then, you can divide by the sampling rate (which is at a fixed
offset in the stream) to find the length in seconds. Finding the average
bitrate from there is trivial - just take file size and divide by stream
length.
Finding the last page in a stream is something you're best off using ogg
for, rather than coding it yourself - libogg itself is pretty small.
Michael
--- >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-dev-request@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.