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?
yes, setting the frame position (arbitrarily) is very expensive. why do you need that ? can't you just read one frame after the other ?