cv::VideoWriter::fourcc('H','2','6','4'), 10, Size(frame_width,frame_height)); code example

Example: cv::VideoWriter::fourcc('H','2','6','4'), 10, Size(frame_width,frame_height));

import cv2# function video capturecameraCapture = cv2.VideoCapture(0)# rame rate or frames per secondfps = 30 # Width and height of the frames in the video streamsize = (int(cameraCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),			int(cameraCapture.get(cv2.CAP_PROP_FRAME_HEIGHT))) """Create a VideoWriter object. We should specify the output file name (eg: MyOutput.avi). Then we should specify the FourCC. Then number of frames per second (fps) and frame size should be passed. May specify isColor flag. If it is True, encoder expect color frame, otherwise it works with grayscale frame.FourCC is a 4-byte code used to specify the video codec. The list of available codes can be found in fourcc.org. It is platform dependent.""" videoWriter = cv2.VideoWriter('MyOutput.avi',     cv2.VideoWriter_fourcc('I','4','2','0'), fps, size) success, frame = cameraCapture.read() # some variablenumFramesRemaining = 10*fps - 1 # loop until there are no more frames and variable > 0while success and numFramesRemaining > 0:    videoWriter.write(frame)    success, frame = cameraCapture.read()    cv2.imshow('frame',frame)    cv2.waitKey(1)    numFramesRemaining -= 1 #Closes video file or capturing devicecameraCapture.release()

Tags:

Cpp Example