笔记
import cv2 cap = cv2.VideoCapture('ex2.mp4') '''修改视频的分辨率''' # fps=10 # size = (224, 224) # # videoWriter = cv2.VideoWriter('ex2.mp4', cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size) # while True: # success, frame = cap.read() # if success: # frame = cv2.resize(frame, size) # videoWriter.write(frame) # else: # print('end') # break '''播放视频''' while(1): ret, frame = cap.read() # print(ret) if ret==True: cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break # Release everything if job is finished cap.release() cv2.destroyAllWindows()