import cv2
import os
import sys
def run(videoFilePath,outputDirectoryPath):
os.chdir(outputDirectoryPath)
print('Source Video : '+videoFilePath)
print('Output Dir : '+outputDirectoryPath)
cap = cv2.VideoCapture(videoFilePath)
frameNumber = 0
while (cap.isOpened()):
ret, frame = cap.read()
if ret is True:
framePath = outputDirectoryPath +'\\'+ str(frameNumber) + '.jpg'
if os.path.isfile(framePath) is False:
cv2.imwrite(framePath, frame)
frameNumber += 1
print('<CMDOUTPUT> PROGRESS '+str(frameNumber))
else:
break
cap.release()
# CMD 인자를 넘겨받아 실행
videoFilePath = str(sys.argv[1])
outputDirectoryPath = str(sys.argv[2])
run(videoFilePath,outputDirectoryPath)
# Quit
quit()