# C1.py
import cv2
Lx=640; Ly=480; F=8; Lx2=int(Lx/F); Ly2=int(Ly/F)
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, Lx)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, Ly)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('cam1.mp4', fourcc, 20.0, (Lx,Ly))
t=0
while(t < 501 and cap.isOpened()):
    ret, frame = cap.read()
    t+=1
    if ret == False: break
    out.write(frame)
    cv2.imwrite('F_'+str(t)+'.png',frame)
    cv2.imshow('frame',frame)
    cv2.waitKey(0)
    if cv2.waitKey(1) & 0xFF == ord('q'): break
cap.release()
out.release()
cv2.destroyAllWindows()
print('C1 is done...')
