import cv2
import os
video_path = r'E:\\data\\ev.avi'
savepath = os.path.join('E:\\data\\ev\\')
ispathexists = os.path.exists( savepath )
if not ispathexists:
os.makedirs(savepath)
vc = cv2.VideoCapture(video_path) #读入视频文件
fps = vc.get(cv2.CAP_PROP_FPS)
print(fps)
c=0
rval=vc.isOpened()
while rval: #循环读取视频帧
c = c + 1
rval, frame = vc.read()
if rval:
savedir = os.path.join( savepath + str(c) + '.png' )
cv2.imwrite(savedir, frame) #存储为图像
print(c)
else:
print('break')
break
vc.release()
print('-----------finish-----------')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)