[theora-dev] Ogg: correspondence between playtime and file offset
giles at xiph.org
Wed Jul 5 14:51:53 PDT 2006
On Sat, Jul 01, 2006 at 09:45:21AM +0800, ramakrishna.p at radixs.com wrote:
> If you can provide formulae or any function, that would be great help to
> provide streaming of ogg files with all the features that typical media
> player should have.
The general algorithm is this: perform a bisection search for the first
page whose granulepos maps to a time prior to your seek point. You can
use all the streams you know how to parse (i.e. vorbis and theora) to do
this. Keep in mind that some pages may have a granulepos of -1 and these
must be ignored. This isn't sufficient for perfect playback, but it is
For theora, this will likely be an predicted frame and so you cannot
actually begin playback there. One option is to start playing audio and
just discard any video packets until the next keyframe. However, the
form of the theora packet granulepos encodes the offset of the previous
keyframe. You can use this to perform a second bisection search, begin
decoding there, and then start playback at the actual seekpoint.
In both cases you can use a cache and the average bitrate to narrow down
the first step of the bisection search.
Hope that helps, and thanks for adding ogg theora support!
More information about the theora-dev