# Opencv 的低错误率的保存方法

  • Opencv 保存个视频一堆错误,有时换个视频就不行了
  • 这里记录下错误率最低的视频保存方法
video = cv2.VideoCapture(file_name)
frame_height, frame_width = int(video.get(3)),int(video.get(4))
fps = video.get(cv2.CAP_PROP_FPS)
save_video_name = video_name + '.avi'
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
save_statue = cv2.VideoWriter(save_video_name,fourcc,fps,(frame_height,frame_width))
while video.isOpened():
    ok,frame = video.read()
    
    if not ok:
        break
	save_statue.write(frame)
	
video.release()
save_statue.release()
cv2.destroyAllWindows()