Skip to content

Instantly share code, notes, and snippets.

@aliyevorkhan
Created September 18, 2020 20:46
Show Gist options
  • Save aliyevorkhan/da13427afabec8963f2be17fc0123686 to your computer and use it in GitHub Desktop.
Save aliyevorkhan/da13427afabec8963f2be17fc0123686 to your computer and use it in GitHub Desktop.
import cv2
path = '/home/orkhan/Desktop/train/'
cap = cv2.VideoCapture('video.mp4')
i = 0
counter = 0
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
if counter % 10 == 0:
cv2.imwrite(path + 'train_img_' + str(i) + '.jpg', frame)
i += 1
counter += 1
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment