Record camera live stream using MoviePy

I'm trying to build an application where I need to show live camera streams to a user, as well as record those streams. I need to do it for multiple cameras (currently I'm starting with one only).

I'm able to achieve this requirement using opencv library, but I've been told by senior to use opencv only for live camera stream and use moviepy to record them. Now, I don't know how to how to handle the latter.

I looked for answers on google and stack overflow, but didn't find any. Please help if you know how to record using moviepy.

Below is the code using opencv:

import numpy as np
import cv2

cap = cv2.VideoCapture("rtsp://admin:vaaan@123@")

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))

    ret, frame =
    # output the frame
    cv2.imshow('Original', frame)

    if cv2.waitKey(1) & 0xFF == ord('a'):