Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, cv2
- from os import walk
- currentWorkingDirectory = os.getcwd()
- files = []
- for (dirpath, dirnames, filenames) in walk(currentWorkingDirectory + "/Video"):
- files.extend(filenames)
- if not files:
- print("== No files found ==")
- else:
- for file in files:
- if ".mp4" in file:
- print(currentWorkingDirectory + "/Video/" + file)
- vidcap = cv2.VideoCapture(currentWorkingDirectory + "/Video/" + file)
- success,image = vidcap.read()
- count = 0
- success = True
- output = currentWorkingDirectory + "/Output/" + file
- if not os.path.isdir(output):
- os.mkdir(output)
- while success:
- cv2.imwrite(output + "/frame" + str(count) + ".jpg", image)
- success,image = vidcap.read()
- print ("Frame - " + str(count) + " of " + file)
- count += 1
- print("\n===============" + len(file) * "=")
- print("== Finished " + file + " ==")
- print("===============" + len(file) * "=" + "\n")
- print("======= Done =======")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement