3

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!

eyllanesc
246k19 gold badges205 silver badges282 bronze badges
asked Sep 12, 2018 at 3:46
2
  • 2
    jumping 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. Commented 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. Commented Sep 24, 2018 at 1:58

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.