Skip to content

Instantly share code, notes, and snippets.

@aravindpai

aravindpai/12_2.py

Created Apr 28, 2020
Embed
What would you like to do?
%%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
You can’t perform that action at this time.