def skip_from_launch(cap, time):
"""
Move the capture to T+time (time can be negative) and returns the frame index.
:param cap: OpenCV capture
:param time: delta time from launch to skip to
:return: index of requested frame
"""
number_of_frames = int(cap.get(cv2.CAP_PROP_FPS) * time) + skip_to_launch(cap)
number_of_frames = max(number_of_frames, 0)
number_of_frames = min(number_of_frames, cap.get(cv2.CAP_PROP_FRAME_COUNT))
cap.set(cv2.CAP_PROP_POS_FRAMES, number_of_frames)
return number_of_frames
评论列表
文章目录