[Libav-user] What's the ultimate correct way of seeking

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Oct 31 00:53:11 CET 2014

wm4 <nfxjfg at ...> writes:

> > int64_t seekPos = ((theFrameIndex/self.frameRate) * 1000000);

As said by wm4, I don't think this can generally work.

> > av_seek_frame(self.formatContext, -1, seekPos, AVSEEK_FLAG_BACKWARD);
> > 
> > It works pretty well for all intra-frame only 
> > codecs I’ve tried so far. However, when using 
> > inter frame codecs like H.264, it doesn’t work 
> > properly.
> No. libavformat will seek to keyframes only

Note that you can request to seek to non-keyframes 
(in H.264), this is significantly faster but will 
output visually broken frames.

Carl Eugen

More information about the Libav-user mailing list