public int ffmpegScreenOne(String filePath, String rtsp) {
List<String> command = new ArrayList<String>();
command.add("/usr/bin/ffmpeg");
command.add("-i");
command.add(rtsp);//文件输入源
command.add("-f");
command.add("image2");
command.add("-q:v");
command.add("2");
command.add("-vf");
command.add("fps=fps=1/1");
command.add("-s");
command.add("1920x1080");//截取的图片大小,格式为:1920x1080
command.add(filePath+"image-%3d.jpg");//文件输出路径,格式为 11.jpg
Runtime runtime = Runtime.getRuntime();
int i = -1;
try {
File file = new File(filePath);
if(!file.exists()){
boolean mkdirs = file.mkdirs();
}
Process exec = new ProcessBuilder(command).start();
BufferedReader br = new BufferedReader(new InputStreamReader(exec.getErrorStream(),"gb2312"), 4096);
String line = null;
while ((line = br.readLine()) != null) {
i++;
}
} catch (Exception e) {
Thread.currentThread().interrupt();
}
return i;
}
java使用ffmpeg间隔一秒截rtsp流图片
最新推荐文章于 2024-06-24 10:58:31 发布