Ask Your Question

Revision history [back]

Again, assuming you are using VideoCapture in HighGUI, you can do set the CAP_PROP_POS_FRAMES property before grabbing/reading the frames. That way the next frame to be read will be from that frame onwards.

https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set

Using this method you can set the CV_CAP_PROP_POS_FRAMES property to the frame number you want to quickly bypass however many frames you want. For example, in python 3 you would do it as:

import cv2
cap = cv2.VideoCapture('path/to/video/file')
start_frame_number = 50
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame_number)

# Now when you read the frame, you will be reading the 50th frame
success, frame = cap.read()