[theora] Searching for keyframes

Chris Pearce chris at pearce.org.nz
Wed Aug 5 15:58:47 PDT 2009


On 6/08/2009 7:43 a.m., Ralph Giles wrote:
> On Wed, Aug 5, 2009 at 12:10 PM, Shayne Wissler<wissler at gmail.com>  wrote:
>
>> I have a routine that searches an Ogg stream for Theora keyframes.  I am using
>> theora_decode_packetin on each packet which is pretty slow.  Is there a way
>> to just extract the granulepos from the stream without decoding all the video
>> data?
>
> You can check if a particular packet is a keyframe with the
> th_packet_iskeyframe() convenience function. That will be much faster
> than actually decoding the packet data. From that and a packet count
> you should be able to reconstruct the per-packet granulepos if you
> need it.

This works great. Don't forget to handle media with non-zero start 
times; initialize your packet count to the granule of the first packet 
with non -1 granulepos.

Chris Pearce.


More information about the theora mailing list