[Vorbis] Howto get playtime

Ralph Giles giles at xiph.org
Thu May 4 08:40:36 PDT 2006


On Thu, May 04, 2006 at 03:29:04PM +0200, Thomas Kuglitsch wrote:

> Searched in Google, browsed xiph vorbis sites but found no good information
> about how to get the current playtime out of the granuleposition of the
> ogg_packet.

If you have a configured vorbis_dsp_state for the packet you can use 
vorbis_granule_time() declared in vorbis/codec.h.

You can also get an approximate value by just dividing by the sample 
rate given in the info header; but this will not be exact for some 
streams. Also keep in mind that streams can have holes in them, 
especially at the beginning, so you may want to take that into
account if you're displaying this to a user.

> Anyone knows if there is any 'Programming with libvorbis' documentation out
> there, cause on xiph's site (http://www.xiph.org/vorbis/doc/) there's
> nothing :(

Yes, this is a very unfortunate ommission. :(

 -r


More information about the Vorbis mailing list