- 0
- 이니스프리
- 조회 수 502
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from moviepy.editor import * import glob, os files = glob.glob( 'd:\\폴더명\\**\\*.*' , recursive = True ) for f in files: if os.path.splitext(f)[ 1 ] = = '.mp4' : clip = VideoFileClip(f, audio = False ) giffile = os.path.splitext(f)[ 0 ] + '.gif' clip.write_gif(giffile, fps = 7 , opt = 'nq' ) size = os.path.getsize(giffile) if size / ( 1024 * 1024 ) > 70 : clip2 = clip.resize( 0.4 ) giffile = os.path.splitext(f)[ 0 ] + '.gif' clip2.write_gif(giffile, fps = 4 , fuzz = 1 , opt = 'nq' ) clip2.close() elif size / ( 1024 * 1024 ) > 20 : clip2 = clip.resize( 0.5 ) giffile = os.path.splitext(f)[ 0 ] + '.gif' clip2.write_gif(giffile, fps = 6 , fuzz = 1 , opt = 'nq' ) clip2.close() clip.close() |
특정 폴더 및 하위 폴더의 MP4 파일을 20MB가 넘지 않도록 GIF 파일로 일관 변환하는 스크립트에요!
※ 주의 : ImageMagick이 설치되어 있지 않으면 일부 옵션에서 에러가 발생할거에요
※ 주의2 : 폴더명이 .gif로 끝나면 에러가 발생하네요 ㅎㄷㄷ
작성자
댓글 0
권한이 없습니다.