Skip to content

Instantly share code, notes, and snippets.

@aryamanarora
Created December 13, 2018 21:27
Show Gist options
  • Save aryamanarora/4138fe77b79cc4217dff12793820e84d to your computer and use it in GitHub Desktop.
Save aryamanarora/4138fe77b79cc4217dff12793820e84d to your computer and use it in GitHub Desktop.
import os
import numpy
import cv2
folder = input("Path to the folder where the videos are: ")
files = os.listdir(folder)
i = 0
n = len(files)
while True:
vid = cv2.VideoCapture(folder + '/' + files[i])
while vid.isOpened():
ret, frame = vid.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
vid.release()
i += 1
i %= n
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment