Team Ai
Apppublic

Coder19/interview_system

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
video.py23 linesDownload Raw Back to utils
1import cv22 3class Video:4    def __init__(self):5        self.is_recording = False6        self.cap = cv2.VideoCapture(0)7        self.writer = None8 9    async def start_recording(self, filename):10        self.writer = cv2.VideoWriter(filename, cv2.VideoWriter_fourcc(*'XVID'), 30, (int(self.cap.get(3)), int(self.cap.get(4))))11        while True:12            ret, frame = self.cap.read()13            if not ret:14                break15            self.writer.write(frame)16            self.is_recording = True17 18    async def stop_recording(self):19        if self.writer:20            self.writer.release()21        self.cap.release()22        cv2.destroyAllWindows()23        self.is_recording = False