Spring으로 FFMPEG 실행 질문있습니다
조회수 440회
Spring을 이용하여 jsp에서 버튼을 누르면 ffmpeg 명령어가 실행되게 만들었습니다.
작동은 잘 하나 영상을 여러개 저장할 때 누락 되는 영상이 생기는 문제가 있습니다.
일단 자바 코드는 이렇습니다.
@ResponseBody
@RequestMapping("saveVideo1.do")
public ModelAndView saveCheck(HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
mav.setViewName("home");
String str1 = request.getParameter("saveState1");
boolean bo1 = Boolean.parseBoolean(str1);
if (bo1 == true) {
try {
Thread.sleep(1000);
SimpleDateFormat format = new SimpleDateFormat ("yyyyMMddHHmmss");
Date time = new Date();
String time1 = format.format(time);
System.out.println(time1);
Runtime run = Runtime.getRuntime();
String videofile = "url주소/playlist.m3u8";
String command = "Z:/TEST/TEST/ffmpeg/bin/ffmpeg.exe -i \"" + videofile + "\" -ss 00:00:00" + " -t 00:04:00" + " -c copy Z:/TEST/TEST/storage/" + "CH1" + time1 + ".mp4";
System.out.println(command);
try{
run.exec("cmd.exe chcp 65001"); // cmd창에서 utf-8로 변환하는 명령
run.exec(command);
} catch(Exception e){
System.out.println("error : " + e.getMessage());
e.printStackTrace();
}
} catch (InterruptedException e1) {
e1.printStackTrace();
}
} else {
System.out.println("saveState1 Failure");
}
return mav;
}
명령문 잘 실행하고 저장도 잘 되는데 10개를 저장하면 8개 정도가 저장되는 등 2개가 저장이 안 되고 누락되는 문제가 있습니다.
이런 경우는 ffmpeg의 문제인가요?
댓글 입력