Skip to content

Commit

Permalink
#4. 동영상 프레임 추출시 별도의 폴더를 생성하여 프레임 이미지를 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
VDoring authored Jul 22, 2021
1 parent fb9c8ba commit 58ec877
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python ver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# 타이틀화면을 표시합니다.
def mainTitle():
os.system('mode con cols=45 lines=10')
os.system('title VFrame Image v0.2')
os.system('title VFrame Image v0.2.1')
print('\n < Video Frame Image Converter >')
print(' ver0.2 - by VDoring\n\n')
print(' ver0.2.1 - by VDoring\n\n')
os.system('pause')

# by VDoring. 2021-07-21
Expand Down Expand Up @@ -62,14 +62,22 @@ def convertFrameImage(filename):
if filename == 'EXIT':
return

output_path = 'outputImage/' + filename[:-4]

try:
if not os.path.exists(output_path):
os.makedirs(output_path)
except OSError:
print('[!] Create directory ERROR [!]')

try:
capture = cv2.VideoCapture('inputVideo/' + filename)

video_frame_all = capture.get(cv2.CAP_PROP_FRAME_COUNT)

while True:
ret, image = capture.read()
cv2.imwrite("outputImage/%d.jpg" %int(capture.get(cv2.CAP_PROP_POS_FRAMES)), image)
cv2.imwrite(output_path+"/%d.jpg" %int(capture.get(cv2.CAP_PROP_POS_FRAMES)), image)
print('Running.. [' + str(int(capture.get(cv2.CAP_PROP_POS_FRAMES))) + '/' + str(int(video_frame_all)) + ']')

except KeyboardInterrupt:
Expand Down

0 comments on commit 58ec877

Please sign in to comment.