Are all audio pages in a Ogg/Vorbis stream the same size? do they have the same playback 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. 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 This way I can give priorities to the pages I have to download for playback. any coments are appreciated... Horacio
On 6/30/05, Horacio Sanson <hsanson@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)*timePerPageYou'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
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)*timePerPageSo 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