Created
April 28, 2020 16:17
-
-
Save aravindpai/242884bdea43468f2546770a525dbd82 to your computer and use it in GitHub Desktop.
This file contains 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
%%time | |
!rm -r frames/* | |
!mkdir frames/ | |
#specify path to video | |
video = "sample.mp4" | |
#capture video | |
cap = cv2.VideoCapture(video) | |
cnt=0 | |
# Check if video file is opened successfully | |
if (cap.isOpened()== False): | |
print("Error opening video stream or file") | |
ret,first_frame = cap.read() | |
#Read until video is completed | |
while(cap.isOpened()): | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
if ret == True: | |
#save each frame to folder | |
cv2.imwrite('frames/'+str(cnt)+'.png', frame) | |
cnt=cnt+1 | |
if(cnt==750): | |
break | |
# Break the loop | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment