python-opencv截图

pip install numpy

pip install python-opencv

import cv2 as cv

timeF = 10
p = "index.mp4"
vc = cv.VideoCapture(p)
c = 1
if vc.isOpened():  # 判断是否正常打开
    rval, frame = vc.read()
else:
    rval = False

print(rval)
while rval:  # 循环读取视频帧
    rval, frame = vc.read()
    if (c % timeF == 0):  # 每隔timeF帧进行存储操作
        cv.imencode('.jpg', frame)[1].tofile("index.jpg")  # win下使用此方式在目录有中文时不会乱码

    c = c + 1
    cv.waitKey(1)

你可能感兴趣的:(python)