[Libav-user] Why does av_seek_frame() not seek to a keyframe?

Hendrik Leppkes h.leppkes at gmail.com
Thu Jul 19 21:54:56 CEST 2012

On Thu, Jul 19, 2012 at 9:47 PM, Michael Bradshaw <
mbradshaw at sorensonmedia.com> wrote:
> Visually, things look ok (aside from the frame being ~1.5 seconds
> after the requested time), but I think that's because ffmpeg just
> keeps reading and decoding until it gets a full frame out, and it
> won't do that until it hits a keyframe, and that it's disguising the
> fact that it's not seeking to a keyframe (or maybe that a packet's
> .flags value is lying). But I could be misunderstanding something.
Thats the whole problem here. The seek code is horrible, and the decoders
have to pick up the slack and ensure they only recover from a keyframe.
Sadly people around here will usually say "but it works when i use the
ffmpeg application", but thats not the only place avformat and avcodec are
used. :p

If you want to do accurate seeks with only avformat, you have to add a lot
of boilerplate on top of it right now - or if you want to do accurate seeks
even with ffmpeg. Sure, if you tell it to seek, it'll output an image, but
it won't be the image at the time you specified, it'll very likely be at a
later point in time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120719/6393d7ef/attachment.html>

More information about the Libav-user mailing list