[FFmpeg-devel] ogg seeking status

Don Moir donmoir at comcast.net
Fri Feb 10 07:05:34 CET 2012

>> On Wed, Feb 08, 2012 at 05:06:29AM -0500, Don Moir wrote:
>>> Open this file like you would normally in some of your own code or
>>> use the MPlayer code to get it opened. I open the audio and video
>>> streams for this file.
>>> Then do: avformat _seek_file (pFormatCtx, videoStreamIndex, INT64_MIN, 
>>> 0x405c,
>>> INT64_MAX);
>>> For this file, the 0x405c corresponds to about 9 minutes.
>>> Start reading packets until you get the first videoStreamIndex
>>> packet using av_read_frame (pFormatCtx, &packet);
>>> The first videoStreamIndex packet should contain 0x1b41 for both the
>>> packet pts and dts values. 0x1b41 a little less than 4 minutes for
>>> the video stream for this file and this is way off.
>> Are you using latest FFmpeg?
>> I run:
>> $ ./mplayer -ss 9:00 bad_seek_not_accurate.ogv  -quiet
> The first patch you did for ogg_read_timestamp did not include 
> ogg_validate_keyframe. When you posted the 2nd patch it did, but it was 
> not clear from your comments if you were going to keep that or not. You 
> said something begrudgingly like: "We could do this and put out a big fat 
> warning or something". I had implemented it both ways but I commented out 
> the one with ogg_validate_keyframe. Not sure I got the email that the 2nd 
> and final patch was commited, but I could have missed that.
> Ok the good news is the seeked to position is now dead on close with 
> ogg_validate_keyframe in place and the changes associated with that.
> The problem now is on the first ogg_packet_read, os->pflags is not set to 
> indicate a keyframe. But we just seeked to a keyframe.

Scratch what I said about problem now. I had one test case in place and 
forgot to turn that one off.

It seems it's all in order now and works very good and very fast. I tested 
index seeks as well as non-index seeks and it all worked perfect. Even the 
so-called bad files. No problem with os->keyframe_seek now as far as I can 

Thanks reimar!

Ogg Skeleton 4 support might be helpful but for now I am happy to get rid of 
the work around code.

More information about the ffmpeg-devel mailing list