1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   | import cv2
 
  def video2pic(videoFile, outputFile):     vc = cv2.VideoCapture(videoFile)     c = 1     if vc.isOpened():         rval, frame = vc.read()     else:         print('error open video!')         rval = False
      timeF = 100       while rval:         print(1)         rval, frame = vc.read()         if c % timeF == 0:             print(2)             cv2.imwrite(outputFile + str(int(c / timeF)) + '.jpg', frame)         c += 1         cv2.waitKey(1)     vc.release()
  if __name__ == '__main__':     videoFile = './test.mp4'       outputFile = './video2pic_res/frame'       video2pic(videoFile, outputFile)
 
  |