import cv2 if __name__ == '__main__': # 指定视频序列 video_name = 'DSC_0239.MOV' capture = cv2.VideoCapture('./video/' + video_name) index = 0 while (capture.isOpened()): ret, frame = capture.read() if ret==True: index += 1 if (index >= 5 and index <= 1000 and (index) % 5 == 0): filename = '1_' + str(int((index)/5)) + '.jpg' print(filename) # 显示帧 # cv2.imshow('img', frame) # 保存帧 cv2.imwrite('./image/1/' + filename, frame) cv2.waitKey(10) else: break capture.release() cv2.destroyAllWindows()
标签:__,视频,间距,name,index,capture,video,序列 From: https://www.cnblogs.com/limitless-coding/p/16906731.html