|
@@ -260,6 +260,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
/**
|
|
|
* web页面实时流接口
|
|
|
+ *
|
|
|
* @param cameraCode
|
|
|
* @param channel
|
|
|
* @return
|
|
@@ -542,26 +543,36 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @PostConstruct
|
|
|
- public void init() {
|
|
|
- historyUrl = caneraConfig.getHistoryUrl();
|
|
|
- ffmpegPath = caneraConfig.getFfmpegPath();
|
|
|
- filePath = caneraConfig.getFilePath();
|
|
|
- transcribeFilePath = caneraConfig.getTranscribeFilePath();
|
|
|
- webUrl = caneraConfig.getWebUrl();
|
|
|
- bakUrl = caneraConfig.getBakUrl();
|
|
|
- bakUrlRtsp = caneraConfig.getBakUrlRtsp();
|
|
|
- rc = redisCache;
|
|
|
- cUtil = cmdCameraUtil;
|
|
|
- sc = serverConfig;
|
|
|
- wsUrl = caneraConfig.getWsUrl();
|
|
|
- recordUrl = caneraConfig.getRecordUrl();
|
|
|
- hkUrl = caneraConfig.getHkUrl();
|
|
|
- host = caneraConfig.getHost();
|
|
|
- appKey = caneraConfig.getAppKey();
|
|
|
- appSecret = caneraConfig.getAppSecret();
|
|
|
- rtmpUrl=caneraConfig.getRtmpUrl();
|
|
|
+ /**
|
|
|
+ * web页面视频回放接口
|
|
|
+ *
|
|
|
+ * @param code
|
|
|
+ * @param startTm
|
|
|
+ * @param endTm
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getRecordList(String code, Date startTm, Date endTm) {
|
|
|
+ PlaybackVo playbackVo = new PlaybackVo();
|
|
|
+ playbackVo.setCameraIndexCode(code);
|
|
|
+ // 格式化时间
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ playbackVo.setBeginTime(dateFormat.format(startTm));
|
|
|
+ playbackVo.setEndTime(dateFormat.format(endTm));
|
|
|
+ playbackVo.setProtocol("ws");
|
|
|
+ //对象转换json字符串
|
|
|
+ String body = JSONObject.toJSONString(playbackVo);
|
|
|
+ //调用天网接口
|
|
|
+ String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
+ JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
|
|
|
+ log.info("outJson-------->" + outJson);
|
|
|
+ if ("0".equals(outJson.getString("code"))) {
|
|
|
+ JSONObject data = outJson.getJSONObject("data");
|
|
|
+ String urls = data.getString("url");
|
|
|
+ return urls;
|
|
|
+ } else {
|
|
|
+ return "调用天网接口失败";
|
|
|
+ }
|
|
|
+// return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "profile/");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -703,36 +714,55 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * web页面视频回放接口
|
|
|
- * @param code
|
|
|
- * @param startTm
|
|
|
- * @param endTm
|
|
|
- * @return
|
|
|
+ * web页面实时流调用的远程天网接口
|
|
|
+ *
|
|
|
+ * @param camerasVo
|
|
|
+ * @param channel
|
|
|
*/
|
|
|
- public static String getRecordList(String code, Date startTm, Date endTm) {
|
|
|
- PlaybackVo playbackVo = new PlaybackVo();
|
|
|
- playbackVo.setCameraIndexCode(code);
|
|
|
- // 格式化时间
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- playbackVo.setBeginTime(dateFormat.format(startTm));
|
|
|
- playbackVo.setEndTime(dateFormat.format(endTm));
|
|
|
- playbackVo.setProtocol("ws");
|
|
|
- //对象转换json字符串
|
|
|
- String body = JSONObject.toJSONString(playbackVo);
|
|
|
- //调用天网接口
|
|
|
- String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
- JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
|
|
|
- log.info("outJson-------->" + outJson);
|
|
|
+ public static void previewURLs(CamerasVo camerasVo, String channel) {
|
|
|
+ /**
|
|
|
+ * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
+ * jsonBody.put("streamType", 0);
|
|
|
+ * jsonBody.put("protocol","rtsp");
|
|
|
+ * jsonBody.put("transmode", 1);
|
|
|
+ * jsonBody.put("expand","streamform=rtp");
|
|
|
+ */
|
|
|
+ camerasVo.setStreamType(0);
|
|
|
+ camerasVo.setProtocol("rtsp");
|
|
|
+ camerasVo.setTransmode(1);
|
|
|
+ camerasVo.setExpand("streamform=rtp");
|
|
|
+ String body = JSONObject.toJSONString(camerasVo);
|
|
|
+ String previewURLs = getPreviewURLs("/api/video/v1/cameras/previewURLs", body);
|
|
|
+ log.info("-------------------------------->>>>>previewURLs" + previewURLs);
|
|
|
+ JSONObject outJson = JSONObject.parse(previewURLs);
|
|
|
if ("0".equals(outJson.getString("code"))) {
|
|
|
+ log.info("outJson----->" + outJson);
|
|
|
JSONObject data = outJson.getJSONObject("data");
|
|
|
String urls = data.getString("url");
|
|
|
- return urls;
|
|
|
- } else {
|
|
|
- return "调用天网接口失败";
|
|
|
+ HttpUtils.sendGet(historyUrl + "rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
}
|
|
|
-// return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "profile/");
|
|
|
}
|
|
|
|
|
|
+ @PostConstruct
|
|
|
+ public void init() {
|
|
|
+ historyUrl = caneraConfig.getHistoryUrl();
|
|
|
+ ffmpegPath = caneraConfig.getFfmpegPath();
|
|
|
+ filePath = caneraConfig.getFilePath();
|
|
|
+ transcribeFilePath = caneraConfig.getTranscribeFilePath();
|
|
|
+ webUrl = caneraConfig.getWebUrl();
|
|
|
+ bakUrl = caneraConfig.getBakUrl();
|
|
|
+ bakUrlRtsp = caneraConfig.getBakUrlRtsp();
|
|
|
+ rc = redisCache;
|
|
|
+ cUtil = cmdCameraUtil;
|
|
|
+ sc = serverConfig;
|
|
|
+ wsUrl = caneraConfig.getWsUrl();
|
|
|
+ recordUrl = caneraConfig.getRecordUrl();
|
|
|
+ hkUrl = caneraConfig.getHkUrl();
|
|
|
+ host = caneraConfig.getHost();
|
|
|
+ appKey = caneraConfig.getAppKey();
|
|
|
+ appSecret = caneraConfig.getAppSecret();
|
|
|
+ rtmpUrl = caneraConfig.getRtmpUrl();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* HTTP流转RTSP流
|
|
@@ -744,8 +774,8 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
@Override
|
|
|
public String call() throws Exception {
|
|
|
// 执行网络请求...
|
|
|
- log.info(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv "+rtmpUrl+"/live/" + code);
|
|
|
- cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv "+rtmpUrl+"/live/" + code);
|
|
|
+ log.info(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv " + rtmpUrl + "/live/" + code);
|
|
|
+ cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv " + rtmpUrl + "/live/" + code);
|
|
|
return "Response";
|
|
|
}
|
|
|
};
|
|
@@ -759,17 +789,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
executor.shutdown();
|
|
|
- return bakUrlRtsp+"/live/"+code;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * RTSP流视频压缩
|
|
|
- */
|
|
|
- public void videoCompression(String code) {
|
|
|
- // 执行网络请求...
|
|
|
- log.info(ffmpegPath + " -i /opt/streams/map/"+code+".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code+".mp4");
|
|
|
- cmdCameraUtil.cmd(ffmpegPath + " -i /opt/streams/map/"+code+".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code+".mp4");
|
|
|
+ return bakUrlRtsp + "/live/" + code;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -937,35 +957,13 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 车载终端实时流调用的远程天网接口
|
|
|
- * @param camerasVo
|
|
|
- * @param channel
|
|
|
+ * RTSP流视频压缩
|
|
|
*/
|
|
|
- public String apiPreviewURLs(CamerasVo camerasVo) {
|
|
|
- /**
|
|
|
- * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
- * jsonBody.put("streamType", 0);
|
|
|
- * jsonBody.put("protocol","rtsp");
|
|
|
- * jsonBody.put("transmode", 1);
|
|
|
- * jsonBody.put("expand","streamform=rtp");
|
|
|
- */
|
|
|
- camerasVo.setProtocol("rtsp");
|
|
|
- camerasVo.setTransmode(1);
|
|
|
- camerasVo.setExpand("streamform=rtp");
|
|
|
- String body = JSONObject.toJSONString(camerasVo);
|
|
|
- String previewURLs = getPreviewURLs("/api/video/v1/cameras/previewURLs", body);
|
|
|
- log.info("-------------------------------->>>>>previewURLs" + previewURLs);
|
|
|
- JSONObject outJson = JSONObject.parse(previewURLs);
|
|
|
- if ("0".equals(outJson.getString("code"))) {
|
|
|
- log.info("outJson----->" + outJson);
|
|
|
- JSONObject data = outJson.getJSONObject("data");
|
|
|
- String urls = data.getString("url");
|
|
|
- return urls;
|
|
|
- }else {
|
|
|
- return "1";
|
|
|
- }
|
|
|
+ public void videoCompression(String code) {
|
|
|
+ // 执行网络请求...
|
|
|
+ log.info(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code + ".mp4");
|
|
|
+ cmdCameraUtil.cmd(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code + ".mp4");
|
|
|
}
|
|
|
|
|
|
// public String stopStream(String cameraIndexCode, String channel) {
|
|
@@ -981,11 +979,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
- * web页面实时流调用的远程天网接口
|
|
|
+ * 车载终端实时流调用的远程天网接口
|
|
|
+ *
|
|
|
* @param camerasVo
|
|
|
- * @param channel
|
|
|
*/
|
|
|
- public static void previewURLs(CamerasVo camerasVo, String channel) {
|
|
|
+ public String apiPreviewURLs(CamerasVo camerasVo) {
|
|
|
/**
|
|
|
* jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
* jsonBody.put("streamType", 0);
|
|
@@ -993,7 +991,6 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* jsonBody.put("transmode", 1);
|
|
|
* jsonBody.put("expand","streamform=rtp");
|
|
|
*/
|
|
|
- camerasVo.setStreamType(0);
|
|
|
camerasVo.setProtocol("rtsp");
|
|
|
camerasVo.setTransmode(1);
|
|
|
camerasVo.setExpand("streamform=rtp");
|
|
@@ -1005,13 +1002,16 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
log.info("outJson----->" + outJson);
|
|
|
JSONObject data = outJson.getJSONObject("data");
|
|
|
String urls = data.getString("url");
|
|
|
- HttpUtils.sendGet(historyUrl + "rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
+ return urls;
|
|
|
+ } else {
|
|
|
+ return "1";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 报警回放本地测试
|
|
|
* 从天网拉回放流,然后根据url把流下载下来变成文件,然后进行视频压缩
|
|
|
+ *
|
|
|
* @param list
|
|
|
* @param alarmPlayTimeValue
|
|
|
*/
|
|
@@ -1020,7 +1020,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
log.info("异步任务开始-----》");
|
|
|
// for (String code : list) {
|
|
|
- String code="42010001541320000024";
|
|
|
+ String code = "42010001541320000024";
|
|
|
PlaybackVo playbackVo = new PlaybackVo();
|
|
|
playbackVo.setCameraIndexCode(code);
|
|
|
// 获取当前时间
|
|
@@ -1051,20 +1051,20 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
// String urls = data.getString("url");
|
|
|
// log.info("--------------->urls::" + urls);
|
|
|
|
|
|
- String FilePath = "/opt/streams/map/"+code+".mp4";
|
|
|
+ String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
// String FilePath = "/opt/streams/map/01ea43e6676f4e47bd6c5cd9e02aa006.mp4";
|
|
|
// try {
|
|
|
// TimeUnit.SECONDS.sleep(62*Integer.parseInt(alarmPlayTimeValue));
|
|
|
// } catch (InterruptedException e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
- Process process = rtspToMP4.StartRecord(ffmpegPath, "rtsp://124.70.58.209:8554/"+code+"/"+code, FilePath);
|
|
|
+ Process process = rtspToMP4.StartRecord(ffmpegPath, "rtsp://124.70.58.209:8554/" + code + "/" + code, FilePath);
|
|
|
log.info("------playbackURLs----->>>>:" + process);
|
|
|
if (null != process) {
|
|
|
map.put(code, process);
|
|
|
}
|
|
|
try {
|
|
|
- TimeUnit.SECONDS.sleep(70*Integer.parseInt(alarmPlayTimeValue));
|
|
|
+ TimeUnit.SECONDS.sleep(70 * Integer.parseInt(alarmPlayTimeValue));
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -1101,4 +1101,26 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
sdate = DateUtils.addDays(sdate, -1);
|
|
|
System.out.println(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, sdate));
|
|
|
}
|
|
|
+
|
|
|
+ public String heartbeatGetPlayFlv() {
|
|
|
+ List<String> pathList = new ArrayList<>();
|
|
|
+ String data = HttpUtils.sendGet(webUrl + "/api/summary");
|
|
|
+ log.info("data------------------>" + data);
|
|
|
+ if (StringUtils.isNotEmpty(data)) {
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
+ JSONArray streamArray = jsonObject.getJSONArray("Streams");
|
|
|
+ // 创建一个新的列表来存储Subscribers字段的值
|
|
|
+ List<String> subList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < streamArray.size(); i++) {
|
|
|
+ JSONObject subObj = streamArray.getJSONObject(i);
|
|
|
+ String subValue = subObj.getString("Subscribers");
|
|
|
+ String PathValue = subObj.getString("Path");
|
|
|
+
|
|
|
+ subList.add(subValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|