In the previous recipes, we learned how to read a video file and extract its frames. This recipe will show you how to write frames and, therefore, create a video file. This will allow us to complete the typical video-processing chain—reading an input video stream, processing its frames, and then storing the results in a new video file.
Writing video sequences
How to do it...
Let's perform the following steps:
- Writing video files in OpenCV is done using the cv::VideoWriter class. An instance is constructed by specifying the filename, the frame rate at which the generated video should play, the size of each frame, and whether or not the video will be created in color:
writer.open(outputFile, // filename codec...