使用 CV2 Video Writer 后无法读取输出视频

Cannot read the output video after using CV2 Video Writer

执行 videowrite.cv2 后,我无法打开 .avi 文件。

有什么办法可以解决问题吗?

能够写入但无法读取,因为它表示数据已损坏。

下面是示例代码 :

day_video = cv2.VideoCapture('/content/gdrive/Shareddrives/Computer Vision/Assignment 2/Q1_day_video.avi')
check, frame = day_video.read()
height, width, _ = frame.shape
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('output_day.avi', fourcc, 20, (height, width))
while day_video.isOpened():
  check, frame = day_video.read()
  if not check:
    out.release()
    break
  new_output = lines_highlighted_day(frame)
  out.write(new_output)

out.release()

更改此行的高度和视频

out = cv2.VideoWriter('output_day.avi', fourcc, 20, (height, width))

out = cv2.VideoWriter('output_day.avi', fourcc, 20, (width, height ))