OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on Images or videos. OpenCV library can be used to perform multiple operations on videos.
Let’s see how to play a video using the OpenCV Python.
To capture a video, we need to create a
VideoCapture object. VideoCapture have the device index or the name of a video file. Device index is just the number to specify which camera. If we pass 0 then it is for first camera, 1 for second camera so on. We capture the video frame by frame.
cv2.VideoCapture(0): Means first camera or webcam. cv2.VideoCapture(1): Means second camera or webcam. cv2.VideoCapture("file name.mp4"): Means video file
Below is the implementation:
Note : Video file should have in same directory where program is executed.
Sample Frame of video :
Related Article : How to play video in reverse mode.
- Python | Play a video in reverse mode using OpenCV
- OpenCV C++ Program to play a video
- Python OpenCv: Write text on video
- Python - Process images of a video using OpenCV
- Python OpenCV: Capture Video from Camera
- Python | Create video using multiple images using OpenCV
- OpenCV Python program for Vehicle detection in a Video frame
- Saving a Video using OpenCV
- OpenCV | Loading Video
- OpenCV C++ Program to blur a Video
- Saving Operated Video from a webcam using OpenCV
- 10 Interesting modules in Python to play with
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Python OpenCV: Meanshift
- Gun Detection using Python-OpenCV
- OpenCV Python Tutorial
- Top Hat and Black Hat Transform using Python-OpenCV
- Python OpenCV | cv2.cvtColor() method
- Python | Image blurring using OpenCV
- OpenCV | Motion Blur in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.