Created
February 26, 2020 08:36
-
-
Save svmihar/8dafdc59df36621298f139ad2db0ef3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import os | |
def extractFrames(pathIn, pathOut): | |
os.mkdir(pathOut) | |
cap = cv2.VideoCapture(pathIn) | |
count = 0 | |
while (cap.isOpened()): | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
if ret == True: | |
print('Read %d frame: ' % count, ret) | |
cv2.imwrite(os.path.join(pathOut, "frame{:d}.jpg".format(count)), frame) # save frame as JPEG file | |
count += 1 | |
else: | |
break | |
# When everything done, release the capture | |
cap.release() | |
cv2.destroyAllWindows() | |
def main(): | |
extractFrames('bigbuckbunny720p5mb.mp4', 'data') | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment