opencv video recording problem
when trying to record video using while loop than the video is geeting paused and when i'm using only if case like if true video.write(frame) but i'm unable to save the video and each time when the video.write () is occuring it's creating a .avg file but it's not opening. this is my code ---> def Connect(self): self.cap = cv2.VideoCapture(0) while(self.cap.isOpened()): ret, frame = self.cap.read() if ret == True: date = datetime.datetime.now() self.displayImage(frame,0) cv2.waitKey() fourcc = cv2.VideoWriter_fourcc(*"XVID") self.out = cv2.VideoWriter('./videos/Video_%s%s%sT%s%s.avi'%(date.year,date.month,date.day,date.hour,date.minute),fourcc, 30, (1280, 720)) if(captureImg): print("capture") cv2.imwrite('./images/img_%s%s%sT%s%s.png'%(date.year, date.month, date.day, date.hour, date.minute),frame) self.captureImg=False # this is the main logic of recording video ,and here something is going wrong. if self.VdoRecord: while(True): out.write(frame) if self.VdoRecord == False: out.release() break self.cap.release() cv2.destroyAllWindows()