ramakrishna.p@radixs.com
2006-Jul-05 14:36 UTC
[theora-dev] Ogg: correspondence between playtime and file offset
Hi, I have modified fenice(streaming server) and mplayer(media client) code to support for ogg container(vorbis+theora). Now I have to implement forward and rewind of an ogg(vorbis+theora)file by time. So I would like to do file seek to start reading the file from that position. Eg:- mplayer will send +10 secs to forward request to fenice through RTSP and fenice should read and send packets from current position+offset. Here I will have to map 10 secs play time to offset. 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. Thanks, Ramakrishna
Ralph Giles
2006-Jul-05 14:51 UTC
[theora-dev] Ogg: correspondence between playtime and file offset
On Sat, Jul 01, 2006 at 09:45:21AM +0800, ramakrishna.p@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 close. 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! -r