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

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();
			}
		}
	}

展开阅读全文

没有更多推荐了,返回首页