|
@@ -1,7 +1,6 @@
|
|
|
package com.persagy.cameractl.service;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.rmi.server.ExportException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
@@ -9,17 +8,17 @@ import java.util.Map;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import com.persagy.cameractl.utils.SdkClient;
|
|
|
-
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
-
|
|
|
+import com.persagy.cameractl.conf.AllStaticConfig;
|
|
|
+import com.persagy.cameractl.service.windows.DpsdkMainWindows;
|
|
|
import com.persagy.cameractl.utils.Camera;
|
|
|
import com.persagy.cameractl.utils.CmdStreamThread;
|
|
|
import com.persagy.cameractl.utils.JsonTools;
|
|
|
import com.persagy.cameractl.utils.OtherTools;
|
|
|
import com.persagy.cameractl.utils.ResultClass;
|
|
|
-import com.persagy.cameractl.conf.AllStaticConfig;
|
|
|
-import com.persagy.cameractl.service.windows.DpsdkMainWindows;
|
|
|
+import com.persagy.cameractl.utils.SdkClient;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
public class DahCameraExecuteApi {
|
|
|
Logger logger = LoggerFactory.getLogger(DahCameraExecuteApi.class);
|
|
@@ -286,6 +285,8 @@ public class DahCameraExecuteApi {
|
|
|
Date endDate = DateUtil.parse(dahCamera.endDateStr);
|
|
|
long endMillSeconds = endDate.getTime();
|
|
|
long endSeconds = endMillSeconds / 1000;
|
|
|
+ // 两者之间相差的秒数
|
|
|
+ long between = DateUtil.between(startDate, endDate, DateUnit.SECOND, true);
|
|
|
|
|
|
// 取得设备编号和通道序号
|
|
|
String[] arrCode = dahCamera.cameraIndexCode.split("\\$");
|
|
@@ -332,15 +333,22 @@ public class DahCameraExecuteApi {
|
|
|
logger.error("调用大华视频回放接口 error,返回信息 = 回放文件名称生成失败");
|
|
|
return new ResultClass(false, "回放文件名称生成失败");
|
|
|
}
|
|
|
+
|
|
|
int retCode = -1;
|
|
|
+ Process p = null;
|
|
|
CmdStreamThread cmdStreamThread = null;
|
|
|
try {
|
|
|
Runtime run = Runtime.getRuntime();
|
|
|
- Process p = run.exec("ffmpeg -i \"" + playBackUrl + "\" -c copy -y \"" + playFilePath + "\"");
|
|
|
+ if ("h265".equals(dahCamera.streamFormat)) {
|
|
|
+ p = run.exec("ffmpeg -i \"" + playBackUrl + "\" -map 0 -c:v libx264 -crf 28 -vf format=yuv420p -c:a copy -y \"" + playFilePath + "\"");
|
|
|
+ } else {
|
|
|
+ p = run.exec("ffmpeg -i \"" + playBackUrl + "\" -c copy -y \"" + playFilePath + "\"");
|
|
|
+ }
|
|
|
|
|
|
// 读取标准输入流、输出流,防止进程阻塞
|
|
|
cmdStreamThread = new CmdStreamThread(p.getInputStream(), p.getErrorStream());
|
|
|
retCode = p.waitFor();
|
|
|
+ //retCode = p.waitFor(between, TimeUnit.SECONDS);
|
|
|
p.destroy();
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -350,7 +358,8 @@ public class DahCameraExecuteApi {
|
|
|
return new ResultClass(false, "ffmpeg抓取rtsp转为mp4时失败");
|
|
|
}
|
|
|
if (retCode == 0) {
|
|
|
-// 正常转换结束
|
|
|
+ //if (retCode) {
|
|
|
+ // 正常转换结束
|
|
|
File mp4File = new File(playFilePath);
|
|
|
String playFileName = mp4File.getName();
|
|
|
String token = OtherTools.getMp4NamePrefix(playFileName);
|