From here download this video so we have the same video file for the test. Make sure to have that mp4 file in the same directory of your python code. Then also make sure to run the python interpreter from the same directory.

Then modify the code, ditch waitKey that's wasting time also without a window it cannot capture the keyboard events. Also we print the success value to make sure it's reading the frames successfully.

import cv2
vidcap = cv2.VideoCapture('big_buck_bunny_720p_5mb.mp4')
success,image = vidcap.read()
count = 0
while success:
  cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file      
  success,image = vidcap.read()
  print('Read a new frame: ', success)
  count += 1

How does that go?

Answer from fireant on Stack Overflow
🌐
Cloudinary
cloudinary.com › home › how to extract frames from video in python
How to Extract Frames from Video in Python | Cloudinary
February 19, 2026 - The timestamps list contains the specific times (in seconds) at which you want to extract frames. The save_frame method saves the frame at each specified timestamp with a filename indicating the exact time. While both MoviePy and OpenCV are both great options for how to extract frames from video in Python, there are certain scenarios where MoviePy shines:
🌐
Medium
medium.com › @haydenfaulkner › extracting-frames-fast-from-a-video-using-opencv-and-python-73b9b7dc9661
Extracting Frames FAST from a Video using OpenCV and Python | by Hayden Faulkner | Medium
July 15, 2020 - UPDATE (JUL 2020): I now use, and suggest the use of decord for faster video loading in Python. You can view the original OpenCV only version further down. :) ... Speed comparisons. Sourced from decord Github page. Below is an example script of how to extract frames using decord.
Discussions

Python - Extracting and Saving Video Frames - Stack Overflow
This is Function which will convert most of the video formats to number of frames there are in the video. It works on Python3 with OpenCV 3+ import cv2 import time import os def video_to_frames(input_loc, output_loc): """Function to extract frames from input video file and save them as separate ... More on stackoverflow.com
🌐 stackoverflow.com
OpenCV/Python: read specific frame using VideoCapture - Stack Overflow
Is there a way to get a specific frame using VideoCapture() method? My current code is: import numpy as np import cv2 cap = cv2.VideoCapture('video.avi') This is my reference tutorial. More on stackoverflow.com
🌐 stackoverflow.com
Extracting frames from a video in python
Not sure if it is exactly what you need, but you could use OpenCV. You can open a video with cv2.VideoCapture("filename"), and then just read() frame by frame. More on reddit.com
🌐 r/learnpython
2
1
May 25, 2021
How to extract frames from a .mp4 video with .ind file using python
What makes you believe that VideoCapture is not able to read mp4 files? This is a serious question. I haven’t used openCV, but I’d think that it would tell you. Can you check to see if the video is opened? Maybe try looking at this: https://learnopencv.com/reading-and-writing-videos-using-opencv/ More on reddit.com
🌐 r/learnprogramming
2
3
October 7, 2021
🌐
api.video
api.video › blog › tutorials › extract-a-set-of-frames-from-a-video-with-ffmpeg-and-python
Extract a set of frames from a video with FFMPEG and Python
April 21, 2021 - You can extract a list of frames at evenly spaced intervals through your video using Python and FFMPEG. This information could be used to do a quick skim of a video or create a trailer for the video programmatically - you could stitch the frames back together afterwards into a short video. If you need a place to upload and host your video from, api.video has you covered!
🌐
FutureLearn
futurelearn.com › home › blog
Extracting video frames using OpenCV
October 25, 2022 - To get this information from a video in OpenCV we need to use the variable CAP_PROP_FPS and the function get as follows: fps = video.get(cv2.CAP_PROP_FPS) print('frames per second =',fps)
Top answer
1 of 14
446

From here download this video so we have the same video file for the test. Make sure to have that mp4 file in the same directory of your python code. Then also make sure to run the python interpreter from the same directory.

Then modify the code, ditch waitKey that's wasting time also without a window it cannot capture the keyboard events. Also we print the success value to make sure it's reading the frames successfully.

import cv2
vidcap = cv2.VideoCapture('big_buck_bunny_720p_5mb.mp4')
success,image = vidcap.read()
count = 0
while success:
  cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file      
  success,image = vidcap.read()
  print('Read a new frame: ', success)
  count += 1

How does that go?

2 of 14
78

To extend on this question (& answer by @user2700065) for a slightly different cases, if anyone does not want to extract every frame but wants to extract frame every one second. So a 1-minute video will give 60 frames(images).

import sys
import argparse

import cv2
print(cv2.__version__)

def extractImages(pathIn, pathOut):
    count = 0
    vidcap = cv2.VideoCapture(pathIn)
    success,image = vidcap.read()
    success = True
    while success:
        vidcap.set(cv2.CAP_PROP_POS_MSEC,(count*1000))    # added this line 
        success,image = vidcap.read()
        print ('Read a new frame: ', success)
        cv2.imwrite( pathOut + "\\frame%d.jpg" % count, image)     # save frame as JPEG file
        count = count + 1

if __name__=="__main__":
    a = argparse.ArgumentParser()
    a.add_argument("--pathIn", help="path to video")
    a.add_argument("--pathOut", help="path to images")
    args = a.parse_args()
    print(args)
    extractImages(args.pathIn, args.pathOut)
🌐
The Python Code
thepythoncode.com › article › extract-frames-from-videos-in-python
How to Extract Frames from Video in Python - The Python Code
In this method, we're not going to use OpenCV, but with another library called MoviePy, I'm going to create a file called extract_frames_moviepy.py and import the necessary modules: from moviepy.editor import VideoFileClip import numpy as np import os from datetime import timedelta · As in the first method, we'll be using the SAVING_FRAMES_PER_SECOND parameter here too: # i.e if video of duration 30 seconds, saves 10 frame per second = 300 frames saved in total SAVING_FRAMES_PER_SECOND = 10
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-extract-frames-using-opencv
Program to extract frames using OpenCV-Python - GeeksforGeeks
August 11, 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.
Find elsewhere
🌐
Educative
educative.io › answers › how-to-extract-images-from-a-video-in-python
How to extract images from a video in Python
It specifies a video source, specifies an output directory for extracted frames, and calls the extract_and_display_frames function with an interval of 20 frames. Extracting frames from a video is a simple yet powerful task that can be quickly accomplished with Python and OpenCV.
🌐
GitHub
github.com › chi0tzp › PyVideoFramesExtractor
GitHub - chi0tzp/PyVideoFramesExtractor: Extract frames from videos in Python using OpenCV. · GitHub
python extract.py --video=demo_videos/talking_dog.mp4 · Extracted frames are stored under extracted_frames/demo_videos/talking_dog_frames/ as follows:
Top answer
1 of 6
77

The following code can accomplish that:

import cv2
cap = cv2.VideoCapture(videopath)
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_number-1)
res, frame = cap.read()

frame_number is an integer in the range 0 to the number of frames in the video.
Notice: you should set frame_number-1 to force reading frame frame_number. It's not documented well but that is how the VideoCapture module behaves.

One may obtain amount of frames by:

amount_of_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
2 of 6
57

Thank you GPPK.

The video parameters should be given as integers. Each flag has its own value. See here for the code.

The correct solution is:

import numpy as np
import cv2

#Get video name from user
#Ginen video name must be in quotes, e.g. "pirkagia.avi" or "plaque.avi"
video_name = input("Please give the video name including its extension. E.g. \"pirkagia.avi\":\n")

#Open the video file
cap = cv2.VideoCapture(video_name)

#Set frame_no in range 0.0-1.0
#In this example we have a video of 30 seconds having 25 frames per seconds, thus we have 750 frames.
#The examined frame must get a value from 0 to 749.
#For more info about the video flags see here: https://stackoverflow.com/questions/11420748/setting-camera-parameters-in-opencv-python
#Here we select the last frame as frame sequence=749. In case you want to select other frame change value 749.
#BE CAREFUL! Each video has different time length and frame rate. 
#So make sure that you have the right parameters for the right video!
time_length = 30.0
fps=25
frame_seq = 749
frame_no = (frame_seq /(time_length*fps))

#The first argument of cap.set(), number 2 defines that parameter for setting the frame selection.
#Number 2 defines flag CV_CAP_PROP_POS_FRAMES which is a 0-based index of the frame to be decoded/captured next.
#The second argument defines the frame number in range 0.0-1.0
cap.set(2,frame_no);

#Read the next frame from the video. If you set frame 749 above then the code will return the last frame.
ret, frame = cap.read()

#Set grayscale colorspace for the frame. 
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

#Cut the video extension to have the name of the video
my_video_name = video_name.split(".")[0]

#Display the resulting frame
cv2.imshow(my_video_name+' frame '+ str(frame_seq),gray)

#Set waitKey 
cv2.waitKey()

#Store this frame to an image
cv2.imwrite(my_video_name+'_frame_'+str(frame_seq)+'.jpg',gray)

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
🌐
Medium
rs-punia.medium.com › how-to-extract-frames-from-a-video-using-python-a-complete-guide-3124618b76cb
How to Extract Frames from a Video using Python — A Complete Guide | by Rampal Punia | Medium
July 5, 2024 - The frames will be saved as image files in a specified output directory. ... Before we get started, you’ll need to have Python3 installed on your system. You’ll also need to install the following packages using pip: ... settings.py: A Python file containing configuration settings for our program. All the default parameters are supplied from this module. frame_extractor.py: This module consists of a Python class `FrameExtractor` that defines the logic for extracting frames from a video.
🌐
Reddit
reddit.com › r/learnpython › extracting frames from a video in python
r/learnpython on Reddit: Extracting frames from a video in python
May 25, 2021 -

Hi,

I am currently working on a project which involves measuring the time dependance of a varying quantity with time. So I have a video and the quantity changes with time in it. Now I want to extract each frame in it (every few seconds- which is input by the user) and then apply operations on it.

So essentially I want to extract frames. Can anyone suggest how do I go about doing this? Is their an automated tool which does this? Or else how can I do this task using python code?

Any advice would be greatly appreciated

TIA!

🌐
YouTube
youtube.com › watch
Extract Frame from Videos using OpenCV in Python | Extracting and Saving Frames in Python - YouTube
In this video, we are going to build a simple python program that will help us to extract frames from a video or a set of videos. We will use the cv.VideoCap...
Published: February 8, 2021
🌐
AskPython
askpython.com › python › examples › extract-images-from-video
How to extract images from video using Python OpenCV? - AskPython
May 14, 2026 - Frame extraction is the process of reading a video file and pulling out individual images (frames) one by one. OpenCV provides the VideoCapture class which handles this. It reads video files from disk or streams from a webcam, and the read() ...
🌐
Kaggle
kaggle.com › general › 491148
Extracting Frames from Video Using Python and OpenCV | Kaggle
However, sometimes it's more convenient to work with individual frames rather than the entire video. This could be useful for tasks like object detection, frame-by-frame analysis, or simply extracting key frames for further processing. In this article, we introduce a Python script that utilizes OpenCV, a powerful computer vision library, to extract frames from a video and save them as individual image files.
🌐
Cloudinary
cloudinary.com › home › how to split videos into frame in python
How to Split Videos into Frame in Python | Cloudinary
November 17, 2025 - ... To extract the frames from a video with Movie.py, we can use the iter_frames function, which iterates over all the frames of a video clip and returns each frame of the clip as a HxWxN Numpy array.
🌐
DataFlair
data-flair.training › blogs › opencv-extract-frames-from-video
OpenCV Project - Extract Frames from a Video - DataFlair
June 1, 2026 - This code uses OpenCV library in Python to save a captured frame as a JPEG image file. The function cv2.imwrite() writes the image data to the specified file path and name, using a format string to include the frame number in the file name. The image data to be saved is provided as the second argument. By this line, we are saving the extracted frame in the specified folder path.