[theora-dev] How to get the duration of a file or track?
giles at xiph.org
Mon Aug 27 16:28:27 PDT 2007
On Mon, Aug 27, 2007 at 06:59:44PM -0400, Ken Larson wrote:
> Thanks, that will come in handy, because I do eventually need to try to
> determine duration of individual frames.
Theora is a fixed framerate codec, so the duration of individual frames
can only change at a chain boundary. Just invert the framerate in the
first header packet to get the frame duration.
> Actually, I phrased my question badly though: What I originally wanted
> to know was how to find the total duration of the movie.
One of us is confused then. That's what I just explained. :)
> >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.
More information about the theora-dev