1 import cv2 2 import os 3 4 dir = r"F:wenjian rainingData_3.3VideoData" 5 6 for eachVid in os.listdir(dir): 7 # vPath = dir + "\" + eachVid 多个视频 8 vPath = r"F:wenjianVID_20210415_142035.mp4" 9 vidcap = cv2.VideoCapture(vPath) 10 success,image = vidcap.read() 11 count = 0 12 while success: 13 if count%90==0: 14 cv2.imwrite(f'F:\wenjian\test\_{count}.jpg', image) # save frame as JPEG file 15 success,image = vidcap.read() 16 print('Read a new frame: ', success) 17 count += 1
视频帧率默认30 FPS,抽帧的采样率为 3秒。