public static void coverterVideo(String in, String out, Integer[] times) {
String prfix_ffmpeg = Contants.getRes("FFMPEG_PATH");
StringBuilder commond = new StringBuilder();
commond.append(prfix_ffmpeg);
commond.append(" -i ");
commond.append(in);
commond.append(" -vcodec copy -acodec copy -f mp4 ");
commond.append(out);
System.out.println(commond.toString());
Process pro = null;
Process pro1 = null;
try {
if(!new File(out).exists()){
System.out.println("***********coverter begin*********");
pro = Runtime.getRuntime().exec(commond.toString());
System.out.println("***********"
+ new SimpleDateFormat("yy-MM-dd HH:MM:ss")
.format(new Date()) + "***********");
doWaitFor(pro);
System.out.println("***********"
+ new SimpleDateFormat("yy-MM-dd HH:MM:ss")
.format(new Date()) + "***********");
System.out.println("**********coverter finished!!!*********");
}
// pro.destroy();
if(new File(out).exists()){
System.out.println("*********************截图开始***********************");
// for(Integer mm : videoTimes){ //videoTimes 时间数组
// StringBuilder commond1 = new StringBuilder();
// commond1.append(prfix_ffmpeg);
// commond1.append(" -i ");
// commond1.append(out);
// commond1.append(" -y -f image2 -ss ");
// commond1.append(mm);
// commond1.append(" -vframes 1 ");
// commond1.append("-s 350*240 ");
// commond1.append("D:/SOFT/ffmpeg/imgs/");
// commond1.append(mm);
// commond1.append(".jpg");
// pro1 = Runtime.getRuntime().exec(commond1.toString());
// doWaitFor(pro1);
// }
System.out.println("*********************截图结束***********************");
}
} catch (Exception e) {
e.printStackTrace();
try {
pro.getErrorStream().close();
pro.destroy();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
ffmpeg 视频转换、图片批量提取
最新推荐文章于 2025-05-16 20:41:21 发布