Seeking robustly is hard.
A good place to start is by looking at liboggz's seeking code in
oggz_seek.c, oggz_bounded_seek_set(). Conrad also has a seek-rewrite
branch in his git repository which cleans up that code significantly.
An example of a program which uses liboggz's seeking is oggplayer. It
uses liboggplay which in turn uses liboggz to seek:
http://www.bluishcoder.co.nz/2009/03/oggplayer-simple-ogg-player-using.html
However, liboggz does not seek back to the theora keyframe prior to your
seek target. So if you use oggz_seek() and just start decoding from
there, you'll get garbage in your theora frames until libtheora hits a
keyframe packet.
This thread has some discussion of some solutions for this:
http://lists.xiph.org/pipermail/theora/2009-July/002544.html
Do you need your seek to be millisecond accurate? If not, you can just
do a rate-estimation (e.g. seek file to offset (file_size /
media_duration) * seek_target), ogg_sync_pageseek(), and then decode
forward from there. VLC takes this approach, and it works well enough.
All the best,
Chris Pearce.
On 20/08/2009 8:05 a.m., Manolache Adrian wrote:> I need to be exposed to a way of seeking theora streams. I have
> repeatedly found the same question asked on a different forums but could
> not find an answer. I'm working on a game and started integrating video
> with theora, the sound works just fine with ogg/vorbis(i find it easy to
> seek using ov_raw_seek for audio files). Could someone please point me
> to some example/code of how can i seek with theora?
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> theora mailing list
> theora at xiph.org
> http://lists.xiph.org/mailman/listinfo/theora