I followed this program tutorial that captures the screen and puts it in a video file. The recording stops when the 'q' button is pressed. However, I didn't want to show the screen in a mini window and just write straight to the file. I am just calling the while loop shown in the tutorial except that I didn't include the part about showing the image to the 'Live' window. Now when I use:
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(np.array(frame))
# cv2.imshow('Live', frame)
if cv2.waitKey(1) == ord('q'):
print('done')
break
it won't detect my pressing q. What is going on here? When I press q the loop should stop right? I am just getting a 44 bit mp4 file as an end result from this. I think it might be because I didn't use imshow so waitkey won't do anything but I am not sure. Is there a way to get it to stop recording on a key press?