Ask Your Question

Revision history [back]

cap.set(CAP_PROP_POS_FRAMES, frame_idx)

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?

click to hide/show revision 2
retagged

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

berak gravatar image

cap.set(CAP_PROP_POS_FRAMES, frame_idx)

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?