i have installed python3-picamera on raspberry pi and i want to record a video and store it in 
**.avi format untill i press "Esc" or 'q'.**
 I found below program but i don't want to use camera.wait\_recording() in my program. I have tried using key = cv2.waitkey(1) & 0XFF, but didn't work. It is throwing 

> 
> syntax error: 'break' outside loop.
> 
> 
> 

```
import time
import cv2   
import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 360)
    camera.framerate = 24
    camera.start_recording('one_day.h264', quality=20, bitrate=750000)
    #camera.wait_recording(24 * 60 * 60)
    key = cv2.waitkey(1) & 0XFF
    if key == ord("q")
          break

    camera.stop_recording()

```