Python OpenCV Writing to Video

In this Python OpenCV lesson we are going to learn about Python OpenCV Writing to Video, basically we want to add a circle in our video.

 

 

This is the complete source code for this lesson.

 

 

 

 

This section of code is for creating and reading from input file. If the input is a camera pass 0  instead of the video filename.

 

 

 

When we want to write a video in OpenCV we need some more works. We need to create a VideoWriter object. first, we should specify the output file name with its format (eg: output.avi). then, we should specify the FourCC code and the number of frames per second (FPS). Lastly, the frame size should be passed.

 

 

 

We want to add a circle in the video, so this code is used for creating a circle.

 

 

 

Run the code and this is the result.

Python OpenCV Writing to Video
Python OpenCV Writing to Video
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.