Jim Smith | 22 Jun 22:58
Favicon

current_granulepos-first_granulepos ?

Hi,

Is it correct to assume that after I get the headers of a stream like theora or vorbis the packet time can be computed as current_granulepos-first_granulepos ?

This would give me the difference between the first media packet that is not a
header and the current packet I decoded most recently. In a live stream I would have a
clock from this calculation starting at zero.


Thanks





_______________________________________________
theora-dev mailing list
theora-dev <at> xiph.org
http://lists.xiph.org/mailman/listinfo/theora-dev
Conrad Parker | 23 Jun 01:43
Favicon

Re: current_granulepos-first_granulepos ?

2008/6/23 Jim Smith <jimjim197 <at> yahoo.com>:
> Hi,
>
> Is it correct to assume that after I get the headers of a stream like theora
> or vorbis the packet time can be computed as
>
> current_granulepos-first_granulepos ?
>
> This would give me the difference between the first media packet that is not
> a
> header and the current packet I decoded most recently. In a live stream I
> would have a
> clock from this calculation starting at zero.

not quite, because the first_granulepos denotes the time of the end of
the last packet in the first page -- if there are many packets in the
first page (as is common for vorbis), then there will be a difference
between the time of the start of the stream and first_granulepos.

Shane Stephens wrote some (nasty) code for calculating this for vorbis
etc. (in http://trac.annodex.net/browser/liboggz/trunk/src/liboggz/oggz_auto.c).
Of course I'd suggest you just use liboggz rather than re-implementing
that.

cheers,

Conrad.

Gmane