Skip to content

Instantly share code, notes, and snippets.

@abdulmoeez1225
Created December 4, 2022 13:37
Show Gist options
  • Select an option

  • Save abdulmoeez1225/d0f8f622b4a9502cde4ee5d09bc62ec7 to your computer and use it in GitHub Desktop.

Select an option

Save abdulmoeez1225/d0f8f622b4a9502cde4ee5d09bc62ec7 to your computer and use it in GitHub Desktop.
# Python3 program to extract and save video frame
# using OpenCV Python
#import computer vision module
import cv2
# define the video path
file = 'IMG_4329.mov'
# capture the video
cap = cv2.VideoCapture(file)
i = 0 # frame index to save frames
# extract and save the video frames
while cap.isOpened():
ret, frame = cap.read()
ret, frame = cap.read()
if ret:
cv2.imwrite('test_frame_'+str(i)+'.png', frame)
i+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment