[theora-dev] How to get the duration of a file or track?

Ken Larson forum at larsontechnologies.com
Mon Aug 27 15:59:44 PDT 2007

Ralph -

Thanks, that will come in handy, because I do eventually need to try to 
determine duration of individual frames.

Actually, I phrased my question badly though:  What I originally wanted 
to know was how to find the total duration of the movie.



Ralph Giles wrote:
> On Thu, Aug 23, 2007 at 07:13:17AM -0400, Ken Larson wrote:
>> I'm starting with the theora player_example.c.  I want to be able to 
>> determine the duration of the audio/video ahead of time, to be able to 
>> display it somewhere.
>> I can't see anything obvious in ogg.h, theora.h, or vorbis.h for this.
> It's a little complicated. First you bisection-search based on the ogg 
> page serial numbers to find all the chain segments. Then you read the 
> bos pages for each chain segment to identify the codecs and get their 
> granulepos mappings. Then you read the first and last data packets for 
> each stream in each chain segment and use those to calculate the 
> duration of each segment. The length of the ogg stream is the sum of the 
> durations of each segment.
>> Can anyone help me with the right place to look to do this?
> You might take a look at liboggplay; it's a convenience library that 
> does this for general streams, as well as general playback marshalling. 
>   http://svn.annodex.net/liboggplay/trunk/include/oggplay/oggplay.h
> HTH,
>  -r
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20070827/f8793678/attachment.htm

More information about the theora-dev mailing list