[Ffmpeg-devel] Seeking and keyframes

Måns Rullgård mru
Sat Jun 18 03:04:49 CEST 2005

Steve Willis <steve at stevewillis.net> writes:

> Greetings,
> Please pardon my novice question. I'm working on a project where the
> user needs to analyze video frame by frame, and possibly cut video at
> any arbitrary frame (not necessarily a keyframe.) This is not the same
> as a typical video player...video does not have to be "played" in
> real-time, just stepped through frame by frame. More importantly, I
> need a way to get a frame for a particular time accurate to the frame
> (not to the closest keyframe.)
> I've been looking at the documentation for av_seek_frame(), and I see
> that it seeks to the first keyframe before the given timestamp by
> default. Is there a simple way to change this behavior so it finds the
> previous keyframe and then regenerates the forward intra-frame to
> exactly match the timestamp?

No.  Libavformat doesn't have access to the decoder to perform the
decoding of the frames after the keyframe up to the requested frame.

> Alternatively, is there a simple way to use ffmpeg to transcode the
> video such that every frame is a keyframe?

You could use mjpeg.

> A final (very beginner) question: why is seeking only to keyframes the
> default? Is it very inefficient to actually generate the exact frame
> for a given timestamp each time a user seeks?

It's somewhat inefficient, but also impossible.

M?ns Rullg?rd
mru at inprovide.com

More information about the ffmpeg-devel mailing list