On Wed, Jan 19, 2005 at 03:17:57PM -0500, Brian Weed wrote:
> Is there an easy way to find out the number of frames in a Theora movie?
> I did not see any field that contained this value.
No, we generally avoid headers that can be wrong, or require multiple
passes, like total length.
The proceedure is this:
For each chain in the Ogg Theora stream, read the keyframe granule shift
field from the info header. Then seek to the last page in the chain
segment and use the granulepos and the granule shift to calculate the
frame number. Add up the maximum frame numbers for each chain segment.
Note that this gives the total number of frames as originally encoded,
and doesn't take into account any holes, like you'd get if you recorded
an icecast http stream. For that you need to at least check the first
frame number as well and subtract off.
You can also scan through and count the number of theora video packets,
since theora is one-frame-per-packet after the initial 3 headers. That's
less efficient though.
-r