Python将视频文件按帧截取为图片
作者:互联网
import cv2 vc = cv2.VideoCapture(r'1.mp4') # 读入视频文件,命名cv n = 1 # 计数 if vc.isOpened(): # 判断是否正常打开 rval, frame = vc.read() else: rval = False timeF = 10 # 视频帧计数间隔频率 i = 0 while rval: # 循环读取视频帧 rval, frame = vc.read() if (n % timeF == 0): # 每隔timeF帧进行存储操作 i += 1 print(i) cv2.imwrite(r'D:\desk\pic\{}.jpg'.format(i),frame) n = n + 1 cv2.waitKey(1) vc.release()
标签:vc,Python,截取,rval,cv2,视频文件,timeF,frame 来源: https://www.cnblogs.com/zxyzy/p/14806506.html