rstp截图优化
This commit is contained in:
parent
82797de267
commit
2d1e6b582e
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import liquibase.pro.packaged.O;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
@ -35,7 +36,7 @@ public class RtspUtils {
|
||||
/**
|
||||
* 遍历500次确保实时图片显示正常图片
|
||||
*/
|
||||
private static int COUNT = 100;
|
||||
private static int COUNT = 500;
|
||||
|
||||
/**
|
||||
* 解析视频地址并截图
|
||||
@ -45,6 +46,7 @@ public class RtspUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void getVideoImagePathByRSTP(String path, String picPath) throws Exception {
|
||||
boolean have = false;
|
||||
//创建rstp流对象
|
||||
FFmpegFrameGrabber grabber = createGrabber(path);
|
||||
try {
|
||||
@ -70,9 +72,13 @@ public class RtspUtils {
|
||||
File file = new File(picPath);
|
||||
//输出文件
|
||||
ImageIO.write(bufferedImage, "jpg", file);
|
||||
have = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!have) {
|
||||
throw new RuntimeException("rstp截取图像失败");
|
||||
}
|
||||
} finally {
|
||||
grabber.stop();
|
||||
grabber.close();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user