不为别的,只为做一个连自己都羡慕的人

python截取视频的某一帧,作为视频的预览图片


import cv2
def getVideoPng(_videoPath, _pngPath):
    # vidcap = cv2.VideoCapture("C:\\Users\\sswc\\Desktop\\gai2\\public\\showPdf\\6f3db1f9-e247-4aa5-bca7-93bae62a0079.mp4")
    vidcap = cv2.VideoCapture(_videoPath)
    success, image = vidcap.read()
    n = 1
    while n < 30:
        success, image = vidcap.read()
        n += 1
    # name = "C:\\Users\\sswc\\Desktop\\gai2\\public\\pdfImages\\6f3db1f9-e247-4aa5-bca7-93bae62a0079.png"
    # name = _pngPath
    imag = cv2.imwrite(_pngPath, image)
    if imag:
        print('ok')
        return 'ok'
    else:
        return 'failed'

 

posted @ 2020-09-15 15:08  升级打怪  阅读(2090)  评论(0编辑  收藏  举报