Problem: Why does cv2.VideoWriter() does not compile the frames read completely?

58 Views Asked by At

I encountered this problem when using detect.py from Ultralytics (YOLOv5). My input video that is 2 minutes and 37 seconds long became produces a video with bounding boxes that is only 1 minute and 19 seconds long.

I currently narrowed down the problem down to cv2.VideoWriter() when I tried to read the frames of my input video using the usual cap.read() in an infinite while loop and then reconstruct the frames back to a single .mp4 file (using cv2.VideoWriter()) wherein the same thing happened (the output video duration decreased).

Upon observation, the output video stopped somewhere in the middle. Although it was still playing from the cap.read() and cv2.imshow(), the cv2.VideoWriter() seemed to stop compiling the frames beyond 1 minute and 19 seconds (not sure but this is a guess regarding why it happened).

This is the question that I raised in the repository of Ultralytics' YOLOv5: https://github.com/ultralytics/yolov5/issues/12372

Kindly view it and scroll down in the comments' section for more details regarding my input video.

Any responses/insights will be much appreciated. Thank you.

0

There are 0 best solutions below