您的位置:首页 > 其它

ffmpeg 视频转换、图片批量提取

2014-08-15 13:33 471 查看
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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: