Extracting Keyframes (I-frames) from a Video [closed]

asked 2019-02-27 13:53:50 -0600

matt.briggs gravatar image

updated 2019-02-27 13:54:51 -0600

First, a definition:

By keyframes, I mean frames in which the encoder has written all pixels instead of just the diff pixels. For example, in Adobe Premiere Pro you can specify the maximum number of frames between "Key Frames" in the export UI here:

image description

Further research, here and here, leads me to believe that these are called "I Frames" or "I-Frames".

I have a task that involves detecting these frames in videos. The range of codecs that must be supported is not specified, so if we can support a "typical" .mp4 file, it should be good enough.

In case any additional clarification is needed, it has been suggested that we can use ffprobe to find the indices of these keyframes like so:

ffprobe -select_streams v -i x.mp4 -print_format json -show_entries frame=pict_type,coded_picture_number

If it is possible, and relatively similar in terms of efficiency, I would like to do this with OpenCV instead so that we don't need to independent executables to solve the problem.

In full disclosure, this is part of a job application 'take home' challenge. I believe posting this question is a valid example of how I might approach that problem "on the job" and I will link to this question in my submission.

The Question

Can OpenCV be used to detect I-Frames? If so, what functions or parameters should I be looking at? Also, if so, would we expect OpenCV to be as efficient at this as ffprobe?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-02-27 14:00:29.774581

Comments

Can OpenCV be used to detect I-Frames?

in short - no.

look at video processing / editing software, not at a computer-vision library.

berak gravatar imageberak ( 2019-02-27 13:58:35 -0600 )edit

Thank you for answering. BTW, Not that I actually care, but your comment could perhaps instead be the accepted answer. Also, instead of closing the question as off-topic, it seems like a useful question regarding the features of OpenCV that could be helpful to someone else trying to solve a similar problem in the future. In-fact I asked the question because it was difficult to find the answer definitely with Google.

matt.briggs gravatar imagematt.briggs ( 2019-02-28 11:42:18 -0600 )edit

i am looking for similar solution, how to extract key-frame that represent whole video. such as i have 3sec long video of expressed emotion angry, now i wants to extract one frame that best describes video as angry.

bond132 gravatar imagebond132 ( 2020-02-12 06:15:47 -0600 )edit