OpenCV comes with many powerful video editing functions. In the current scenario, techniques such as image scanning and face recognition can be accomplished using OpenCV. OpenCV library can be used to perform multiple operations on videos. Let’s try to do something interesting using CV2. Take a video as input and break the video into frame by frame and save those frames. Now, a number of operations can be performed on these frames. Like reversing the video file or cropping the video etc. For playing video in reverse mode, we need only to store the frames in a list and iterate reverse in the list of frames. Use the reverse method of the list to reverse the order of frames in the list.
Function Used:
VideoCapture(File_path) : Read the video(.mp4 format)
read(): Read data depending upon the type of object that calls imwrite(filename, img[, params]) : Saves an image to a specified file.
Below is the implementation:
Python3
import cv2
def FrameCapture(path):
vidObj = cv2.VideoCapture(path)
count = 0
success = 1
while success:
success, image = vidObj.read()
cv2.imwrite( "frame%d.jpg" % count, image)
count + = 1
if __name__ = = '__main__' :
FrameCapture( "C:\\Users\\Admin\\PycharmProjects\\project_1\\openCV.mp4" )
|
Output: 
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
04 Jan, 2023
Like Article
Save Article