首先下载ffmpeg解压下载位置:https://download.youkuaiyun.com/download/weixin_39041673/10333948
建立一个bat文件
start
G:/ffmpeg/bin/ffmpeg.exe -i %
1
-ss
20
-vframes
1
-r
1
-ac
1
-ab
2
-s
160
*
120
-f image2 %
2
exit
G:/ffmpeg/bin/ffmpeg.exe ffmpeg的路径 %1
%
2
和C语言有点相似是为传参数保留位置20
要截取多少秒后的图片
打开MyEclipse,建立一个工程 ,以及一个java文件
package com.yizhi.report.application.export.exam;
import java.io.IOException;
public class Ffmpeg {
public static void main(String[] args) {
//视频文件
String videoRealPath = "F://瞬间.flv";
//截图的路径(输出路径)
String imageRealPath = "F://a.jpg";
try {
//调用批处理文件
Runtime.getRuntime().exec(
"cmd /c start F://ffmpeg.bat " + videoRealPath + imageRealPath);
} catch
(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}