[Vorbis-dev] Ogg Pages Play Time?

Michael Smith mlrsmith at gmail.com
Wed Jun 29 10:57:17 PDT 2005


On 6/30/05, Horacio Sanson <hsanson at moegi.waseda.jp> wrote:
> 
> Are all audio pages in a Ogg/Vorbis stream the same size? do they have the
> same playback duration?

No. They will typically vary greatly in both size and duration.


> 
> 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.

The granulepos values in the ogg page headers will allow you to
calculate the duration of a particular page.

> 
> Something like
> 
> numCurrPages = Total of Ogg Pages already downloaded
> timePerPage     = Playback duration of one Page
> curPagePlaying = Current Ogg Page being decoded and played
> nextPage                = numCurrPages + 1
> 
> download nextPage before (numCurrPages - curPagePlaying)*timePerPage

You'll have to do a more complex calculation:

download next page before (granulepos of last page already present -
granulepos of currently playing sample)/sampling frequency.

This isn't greatly more difficult, though... You'll note that in this,
the total number of pages, and the size of each page, is totally
irrelevant.

Mike


More information about the Vorbis-dev mailing list