A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-program-extract-frames-using-opencv/ below:

Program to extract frames using OpenCV-Python

Program to extract frames using OpenCV-Python

Last Updated : 11 Aug, 2025

Extracting individual frames from a video is a fundamental task in video processing. With OpenCV in Python, we can capture each frame sequentially from a video file or camera stream and save them as separate image files. This technique is widely used in applications such as motion analysis, object tracking and dataset creation for machine learning.

Prerequisites:

Installation

You can install OpenCV using pip:

pip install opencv-python

Python Implementation Python
import cv2
vid = cv2.VideoCapture("C:\\Users\\Admin\\PycharmProjects\\project_1\\openCV.mp4")

count, success = 0, True
while success:
    success, image = vid.read() # Read frame
    if success: 
        cv2.imwrite(f"frame{count}.jpg", image) # Save frame
        count += 1

vid.release()

Output:

Explanation:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4