OpenCV Video Capture

Please help me this . I have written just like what Prateek sir was telling in the video.

I think since the video frame is not captured, it is throwing the error,
use this line instead-

ret, frame = cap.read()
if ret == False:
continue
gframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

  • this may remove that problem of improper video capture