python ffmpeg라이브러리가 아닌 cmd에서 ffmpeg으로 영상 자르기
input_file = 자를 영상
save_path = 저장될 영상
start_time = 자를 부분 시작 시간
duration = 몇초를 자를건지
(start_time이 10 이고 dutation이 3이면 10초 - 13초 구간이 잘리게 된다 )
subprocess로 잘리고 에러가 나면 subprocesss에서 에러를 받아서 처리 한다.
input_file = f'./{input_file}'
save_path = f'./{save_path}'
command = f'ffmpeg -i {input_file} -ss {start_time:.3f} -t {duration:.3f} -c copy {save_path} -y'
print(f'command : {command}')
try:
subprocess.run(command.split(), check=True)
print(f"영상 자르기 완료")
except subprocess.CalledProcessError as e:
print(f"오류 발생: {traceback.format_exc()}")