[theora] OGGZ Seeking in Theora
s_weber at blyth.ch
Tue Jun 29 06:09:35 PDT 2010
Thanks a bunch, that's probably the best approach for now.
Am 28.06.2010 16:09, schrieb chris at pearce.org.nz:
> On Mon 28/06/10 7:57 PM , Stefan Weber s_weber at blyth.ch sent:
>> I'd really like to implement a correct seeking functionality.
> A quick hack to get visual artifact free seeking with liboggz is to seek to a time which should lie before a keyframe prior to your seek target, and then decode forwards to the target frame. This will mean seeking takes a few more MS (since you'll likely be decoding more than required), but it's better than visual artifacts after seeking, and is easy to implement to get seeking working.
> We can calculate the maximum time between frames as:
> max_keyframe_interval_ms = ((1<< th_info.keyframe_granule_shift) - 1) * th_info.fps_denominator / th_info.fps_numerator
> So seek to max_keyframe_interval_ms before your target and pump the decode until you reach the target frame. You may need to subtract a few extra milliseconds in there if you're not using the seek-rewrite branch of liboggz to work around old edge-edge case bugs.
> All the best,
> Chris P.
>> Whats the best method to get the time representation of a frame?
>> Am 21.06.2010 11:58, schrieb Stefan Weber: Dear all
>> Conrad, thank you for your inputs and your help so far. I will use
>> and test the seek-rewrite branch as soon as possible.
>> I figured out that the Keyframe position in the granulepos is the
>> NUMBER of the keyframe. When seeking with OGGZ, one has to supply the
>> TIME-position (milliseconds) of the desired frame. So I made a short
>> workaround by calculating the milliseconds position as follows:
>> ms = (granulepos>> shift) * 1000 / noFPS;
>> Needless to say, this won't point me to the exact keyframe
>> position. Probably this rough calculation is not exact enough?
>> What is the best approach to calculate the TIME-position for
>> oggz-seeking out of a given frame number?
>> Kind regards,
More information about the theora