I encounter a problem recently. I want to get some frames form a video in mp4 format. I am using opencv3. My code is as below:
video.set(cv2.CAP_PROP_POS_FRAMES, ind)
ret, img = video.read()
And I found video.set() function is time costing. It running times varies from 20ms to 120ms. But I want to read 7 frames at a total time below 100ms, is it possible? Is it possible under python? PS. Speed is really all that matters. I'm not fixated on OpenCV. Whatever works best. Thank you!
-
2jumping in videos is often expensive because encoders often only represent frames as differences from previous frames. So to extract a single image, you often have to decode multiple frames, starting from the last keyframe before the wanted image.Micka– Micka2018年09月12日 04:29:12 +00:00Commented Sep 12, 2018 at 4:29
-
1@Micka Tanks for your answer, thus I know why it is slow. So I decide to avoid jumping between frames. This really works. Thank you.ToughMind– ToughMind2018年09月24日 01:58:13 +00:00Commented Sep 24, 2018 at 1:58
lang-py