ffmpeg

截取指定时间的缩微图
ffmpeg -i test.avi -y -f image2 -ss 8 -t 0.001 -s 350x240 test.jpg
-ss后跟的时间单位为秒


http://fackyou200.iteye.com/blog/1295316

http://www.toplee.com/blog/303.html

import java.io.File;
import java.util.List;

public class TestFFmpeg {
	public static String ffmpegpath = "F:\\test\\ffmpeg\\ffmpeg.exe"; // ffmpeg.exe的目录
	public static String filepath = "F:\\test\\ffmpeg\\test.avi";

	public static void main(String args[]) {
		processImg(ffmpegpath, filepath);
	}
	//	将filepath 100处截取成图片
	//	<%=ffmpegPath%> -i <%=filepath> -y -f image2 -ss 100 -t 0.001 -s 320x240 <%=desFileName>.jpg
	//	ffmpeg -i test.avi -y -f image2 -ss 8 -t 0.001 -s 350x240 test.jpg 
	//	截图 filepath 从开始 截取2分钟的视频转换成图片 -ss 开始时间 -t结束时间 -vcodec 指定采用的编码器
	//	ffmpeg -i test.avi 1m%04d.jpg -vcodec mjpeg -ss 0:0:0 -t 0:2:0
	//	将一段视频输出为图片序列
	//	ffmpeg -i 1.avi cat%d.png -vcodec png
	//	参考http://os.51cto.com/art/201109/289496.htm
	public static boolean processImg(String ffmpegPath, String filePath) {
		File file = new File(filePath);
		String desFileName = file.getPath().substring(0,
				file.getPath().lastIndexOf("."));
		List<String> commend = new java.util.ArrayList<String>();
		commend.add(ffmpegPath);
		commend.add("-i");
		commend.add(filePath);
		commend.add("-y");
		commend.add("-f");
		commend.add("image2");
		commend.add("-ss");
		commend.add("100");
		commend.add("-t");
		commend.add("0.001");
		commend.add("-s");
		commend.add("320x240");
		commend.add(desFileName + ".jpg");
		try {
			ProcessBuilder builder = new ProcessBuilder();
			builder.command(commend);
			builder.start();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值