fourcc = cv2.VideoWriter_fourcc(*"XVID") writer = cv2.VideoWriter(VIDEO_STREAM_OUT, fourcc, 30, (masked_frame.shape[1], masked_frame.shape[0]), True)