cap.set(CAP_PROP_POS_FRAMES, frame_idx)

asked 2017-11-14 07:56:23 -0600

updated 2017-11-14 08:15:12 -0600

berak gravatar image

I have a video mp4 and I want to extract frames from it. The following code:


t1 = time.time()

cap.set(cv2.CAP_PROP_POS_FRAMES, sample_frame) # here is too slow.

t2 = time.time()

ret, frame = cap.read()


Is there a faster way for me to extract frame from video?

edit retag flag offensive close merge delete

Comments

1

yes, setting the frame position (arbitrarily) is very expensive. why do you need that ? can't you just read one frame after the other ?

berak gravatar imageberak ( 2017-11-14 10:45:04 -0600 )edit