Extracting image from video at a given time using OpenCV

后端 未结 3 2080
深忆病人
深忆病人 2021-02-01 09:39

My task is to make a utility that can take a video and time in seconds.

The utility should write out jpeg images from the video with the given input.

E.g. let th

3条回答
  •  Happy的楠姐
    2021-02-01 10:03

    why don't you just do, what @micka proposed ?

    import cv2
    
    vidcap = cv2.VideoCapture('d:/video/keep/Le Sang Des Betes.mp4')
    vidcap.set(cv2.CAP_PROP_POS_MSEC,20000)      # just cue to 20 sec. position
    success,image = vidcap.read()
    if success:
        cv2.imwrite("frame20sec.jpg", image)     # save frame as JPEG file
        cv2.imshow("20sec",image)
        cv2.waitKey()                    
    

提交回复
热议问题