Home > Back-end >  Cannot read the output video after using CV2 Video Writer
Cannot read the output video after using CV2 Video Writer

Time:10-02

I didn't managed to open the .avi file after i have performed videowrite.cv2.

Is there any way to solve the issues?

Able to write but not able to read as it said corrupted data.

Below is the sample code :

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()

can't play

CodePudding user response:

Change the height & video in this line

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

to

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