#coding=utf8
#有中文要加这句
import cv2
import os
def spilt(path):
if not os.path.exists(path):
os.mkdir(path)
vc = cv2.VideoCapture('Test.mp4') # 读入视频文件
sum = vc.get(7) # 7 代表视频总帧数
c = 0
timeF = int(sum/30) # 视频帧计数间隔频率
i = 0 #计数
while True: # 循环读取视频帧
rval, frame = vc.read()
if rval==True:
if (c % timeF == 0): # 每隔timeF帧进行存储操作
#count_zero = 6-len(str(i))
cv2.imwrite(path + '%06d.jpg' %i, frame) # 存储为图像
with open('name.txt','a') as f: #a表示追加
f.write('%06d'%i+'\n')
i = i + 1
c = c + 1
else:
break
vc.release()
cv2.destroyAllWindows()
if __name__=='__main__':
spilt('./images/')