import cv2
import os
def video_to_frames(video, path_output_dir):
# extract frames from a video and save to directory as 'x.png' where
# x is the frame index
vidcap = cv2.VideoCapture(video)
count = 0
while vidcap.isOpened():
success, image = vidcap.read()
if success:
cv2.imwrite(os.path.join(path_output_dir, '%d.png') % count, image)
count += 1
else:
break
cv2.destroyAllWindows()
vidcap.release()
video_to_frames('VID_20190706_222120.mp4', './out')
Saturday, 6 July 2019
Video to Image Converter using OpenCV Python
Subscribe to:
Posts (Atom)