[theora] OGGZ Seeking in Theora

Stefan Weber s_weber at blyth.ch
Fri Jun 4 03:16:47 PDT 2010

Dear all

I'm aware that there have been several discussions about the seeking 
issue and I'm sorry to bring this up again.
To solve the problem with Inter-Frame garbage, a seek to the previous 
keyframe has to be made. The keyframe number should be extracted from 
the granulepos of the frame where we want to seek to. I hope I 
understood the theory - unfortunately a few questions have rised during 

- How do I extract the keyframe number? Is shifting the granule position 
by "keyframe_granule_shift" correct?
- How can this be implemented using the OGGZ library? My current, 
_UGLY_, approach is the following:
   a) At the start of seeking, set the Packet-/Page-Callback to a new 
   b) A first OGGZ seek jumps to the desired frame number.
   c) OGGZ read() with some Bytes is called until the Seek-Packet/Page 
Callback was executed
   d) In the callback function, I get the granule pos 
(ogg_page_granulepos or oggz_tell_granulepos?), then I extract the 
keyframe number by shifting the granule position.
   e) A final OGGZ seek is made to the calculated keyframe number.
   f) Set callback(s) back to the actual data decoding functions.

As the callbacks are being called asynchronously, I'm not even sure if 
my seek callback is being called with the desired frames/packets.
I hope my question was not too confusing...

Thanks for your help and any replies.

More information about the theora mailing list