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

Hendrik Leppkes h.leppkes at gmail.com
Thu Jul 19 09:34:03 CEST 2012


On Thu, Jul 19, 2012 at 9:25 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:

> So if the file is ~2GB and (as a user) I seek approximately to
> the middle of the video and decide to seek back then, the
> video should be decoded from the beginning to find the keyframe
> before the position I want to seek to?
> (I am just trying to find out if I am correct in my believe that
> it is not generally possible / useful to seek to the latest
> keyframe before the requested position, but that the only
> realistic approach is to seek to the nearest keyframe at or later
> than requested.)
>

You don't need to decode to find keyframes, this is what the codec parsers
are meant to determine.
You also don't need to start from the beginning of the file, you can jump a
pre-determined amount before time X and look for a keyframe, if none is
found jump back a bit more, etc.
Ignoring the special case of intra-refresh H264 streams which do not have
real key-frames (and maybe other formats with similar mechanics), this
should work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120719/1513348e/attachment.html>


More information about the Libav-user mailing list