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
def extract_multiple_videos(intput_filenames, image_path_infile): | |
"""Extract video files into sequence of images.""" | |
i = 1 # Counter of first video | |
# Iterate file names: | |
cap = cv2.VideoCapture('your_video_file_path.avi' or intput_filenames) | |
if (cap.isOpened()== False): | |
print("Error opening file") | |
# Keep iterating break | |
while True: | |
ret, frame = cap.read() # Read frame from first video | |
if ret: | |
cv2.imwrite(os.path.join(image_path_infile , str(i) + '.jpg'), frame) # Write frame to JPEG file (1.jpg, 2.jpg, ...) | |
# you can uncomment this line if you want to view them. | |
# cv2.imshow('frame', frame) # Display frame for testing | |
i += 1 # Advance file counter | |
else: | |
# Break the interal loop when res status is False. | |
break | |
cv2.waitKey(50) #Wait 50msec | |
cap.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment