[Vorbis-dev] Ogg Pages Play Time?

Ralph Giles giles at xiph.org
Wed Jun 29 11:29:47 PDT 2005


On Wed, Jun 29, 2005 at 11:30:22PM +0000, Horacio Sanson wrote:

> Are all audio pages in a Ogg/Vorbis stream the same size? do they have the 
> same playback duration?

No, they are of arbitrary duration. The granulepos field in the header of
the Ogg Vorbis pages tells you total count of how many samples are decodable
including that page, so you can use that for a rough idea. Of course,
because vorbis is variable bitrate it provides no guarantee about the
next page.

> I am developing a P2P streaming application where each client has to dowload 
> the Ogg/Vorbis pages from other clients (peers) but I need to know how much 
> time I have to download the next Ogg/Vorbis page before the playback reaches 
> it.

Have you considered just keeping a buffer of some fixed size and pulling
pages often enough to keep it full while the decoder drains it? This is how
normal http unicast streaming clients work.

> download nextPage before (numCurrPages - curPagePlaying)*timePerPage

So you could calculate timePerPage as a sort of running average over recent
page durations, and try and stay a couple of standard deviations ahead. That
might be a more sophisticated approach.

> any coments are appreciated...

Sounds like an interesting application. I'd like to hear how it develops.

 -r


More information about the Vorbis-dev mailing list