Webcam Video Stream -> Capture Video -> Process Frames -> Save Video -> Processed Video
- Video : collection of images shown rapidly
- Webcam : records the live video
- Frame by Frame processing : processing each image(frame) from the collection of images
- helps to open webcam , video file ; enables us to read frame by frame ; display single frame or frame by frame.
- basically read frames
- source -> to operate webcam { 0 : in-built webcam , 1 : external webcam }
This process is a little complex so we are going to break it down into 2 levels.
-
Level 1
- VideoCapture(0) -> VideoWriter() -> cap.release()
-
Level 2
- open webcam -> what will be the width and height of the frame in video
- start recording -> start saving the file -> show saved frames -> quit
Now lets understand cv2.VideoWriter()
Syntax -> cv2.VideoWriter(filename , codec , fps , frame_size)
-
codec -> saves in .mp4 or .avi(audio video interleave) generally .avi using XVIDCodec ; these things must be given in compression code format
-
fps -> frame per second , how smooth you want your video to be
This method is used to play a video using OpenCV. The whole loop we use during cv2.VideoCapture() is used in here but instead of recording that is passing 0 as source
we pass the video location.