[Ffmpeg-devel] Seeking and keyframes

Steve Willis ffmpeg
Sat Jun 18 04:52:33 CEST 2005

Thanks for the quick reply! Just to clarify, are you recommending my 
program transcode all video files to mjpeg format before the user 
processes them? If so, will this transcoding process preserve the exact 
number of frames from the original format? My program is to be used by 
engineers to analyze high-speed video frame-by-frame, so any conversion 
process cannot introduce new frames or delete old ones.

Any other thoughts on the best way to allow users to step through frames 
forwards and backwards are much appreciated!


M?ns Rullg?rd wrote:
> Steve Willis <steve at stevewillis.net> writes:
>>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.

More information about the ffmpeg-devel mailing list