Reading keyframes FFMPEG

I am trying to write a C ++ program that will read keyframes from a video file using ffmpeg. So far, I managed to get all the frames using av_read_framewhere you sequentially read frame by frame.

But I have some problems with use av_seek_frame, which (if I'm right) was supposed to do the trick for keyframes.

int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);

I have FormatContext, but what other valid arguments only all keyframes consistently receive?

Is there any other function that I can use?

thank

EDIT: In av_read_frameI get an AVPacket that I can use to get the frame data, but how can I get the packet using av_seek_frame?

SOLUTION: OK in AVFrame-> key_frame is a simple boolean. True if its keyframe

+3
source share
1 answer

av_seek_frame has the ability to search for a specific timestamp in a video file. It takes 4 parameters: pointer to AVFormatContext, stream index, timestamp for search, and flags to select the direction and search mode.

The function will then search for the first keyframe to the specified timestamp.

See the documentation for this feature for more information .

+2
source

All Articles