|
@@ -1,6 +1,7 @@
|
|
|
package com.ozs.utils;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
|
@@ -251,6 +252,38 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
public static String getPlayFlv(String cameraCode, String channel) {
|
|
|
+// List<String> pathList = new ArrayList<>();
|
|
|
+// String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
|
|
|
+// if (StringUtils.isNotEmpty(data)) {
|
|
|
+// JSONArray jsonArray = JSONArray.parseArray(data);
|
|
|
+// for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+// String name = jsonObject.getString("Path");
|
|
|
+// pathList.add(name);
|
|
|
+// }
|
|
|
+// boolean contains = pathList.contains(cameraCode + "/" + channel);
|
|
|
+// if (contains) {
|
|
|
+// return getPlayFlv(cameraCode, channel, true);
|
|
|
+// } else {
|
|
|
+// /**
|
|
|
+// * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
+// * jsonBody.put("streamType", 0);
|
|
|
+// * jsonBody.put("protocol","rtsp");
|
|
|
+// * jsonBody.put("transmode", 1);
|
|
|
+// * jsonBody.put("expand","streamform=rtp");
|
|
|
+// */
|
|
|
+// CamerasVo camerasVo = new CamerasVo();
|
|
|
+// camerasVo.setCameraIndexCode(cameraCode);
|
|
|
+// camerasVo.setStreamType(0);
|
|
|
+// camerasVo.setTransmode(1);
|
|
|
+// camerasVo.setProtocol("rtsp");
|
|
|
+// camerasVo.setExpand("streamform=rtp");
|
|
|
+// previewURLs(camerasVo, channel);
|
|
|
+// return getPlayFlv(cameraCode, channel, true);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// return "流媒体目前没有RTSP协议的流";
|
|
|
+// }
|
|
|
return getPlayFlv(cameraCode, channel, true);
|
|
|
}
|
|
|
|
|
@@ -655,8 +688,28 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static List<Map<String, Object>> getRecordList(String channel, Date startTm, Date endTm) {
|
|
|
- return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "profile/");
|
|
|
+ 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 previewURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
+ JSONObject outJson = (JSONObject) JSONObject.parse(previewURLs);
|
|
|
+ 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/");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -862,7 +915,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void previewURLs(CamerasVo camerasVo) {
|
|
|
+ public static void previewURLs(CamerasVo camerasVo, String channel) {
|
|
|
/**
|
|
|
* jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
* jsonBody.put("streamType", 0);
|
|
@@ -881,36 +934,38 @@ 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() + "/" + camerasVo.getCameraIndexCode() + "&save=0");
|
|
|
+ HttpUtils.sendGet(historyUrl + "rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void playbackURLs(List<String> list) {
|
|
|
+ log.info("--------------->playbackURLs");
|
|
|
CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
for (String code : list) {
|
|
|
- PlaybackVo playbackVo = new PlaybackVo();
|
|
|
- playbackVo.setCameraIndexCode(code);
|
|
|
- // 获取当前时间
|
|
|
- LocalDateTime currentTime = LocalDateTime.now();
|
|
|
- // 获取当前时间的前10分钟时间
|
|
|
- LocalDateTime beforeTenMinutes = currentTime.minusMinutes(10);
|
|
|
- // 获取当前时间的后10分钟时间
|
|
|
- LocalDateTime afterTenMinutes = currentTime.plusMinutes(10);
|
|
|
- // 格式化时间
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
|
|
|
- playbackVo.setEndTime(afterTenMinutes.format(formatter));
|
|
|
- //对象转换json字符串
|
|
|
- String body = JSONObject.toJSONString(playbackVo);
|
|
|
- //调用天网接口
|
|
|
- String previewURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
- JSONObject outJson = (JSONObject) JSONObject.parse(previewURLs);
|
|
|
- if ("0".equals(outJson.getString("code"))) {
|
|
|
- log.info("outJson----->" + outJson);
|
|
|
- JSONObject data = outJson.getJSONObject("data");
|
|
|
- String urls = data.getString("url");
|
|
|
- streamUrlDownload(urls, playbackVo.getCameraIndexCode());
|
|
|
- }
|
|
|
+// PlaybackVo playbackVo = new PlaybackVo();
|
|
|
+// playbackVo.setCameraIndexCode(code);
|
|
|
+// // 获取当前时间
|
|
|
+// LocalDateTime currentTime = LocalDateTime.now();
|
|
|
+// // 获取当前时间的前10分钟时间
|
|
|
+// LocalDateTime beforeTenMinutes = currentTime.minusMinutes(10);
|
|
|
+// // 获取当前时间的后10分钟时间
|
|
|
+// LocalDateTime afterTenMinutes = currentTime.plusMinutes(10);
|
|
|
+// // 格式化时间
|
|
|
+// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+// playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
|
|
|
+// playbackVo.setEndTime(afterTenMinutes.format(formatter));
|
|
|
+// //对象转换json字符串
|
|
|
+// String body = JSONObject.toJSONString(playbackVo);
|
|
|
+// //调用天网接口
|
|
|
+// String previewURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
+// JSONObject outJson = (JSONObject) JSONObject.parse(previewURLs);
|
|
|
+// if ("0".equals(outJson.getString("code"))) {
|
|
|
+// log.info("outJson----->" + outJson);
|
|
|
+// JSONObject data = outJson.getJSONObject("data");
|
|
|
+// String urls = data.getString("url");
|
|
|
+ log.info("--------------->code::"+code);
|
|
|
+ streamUrlDownload("rtsp://124.70.58.209:8554/42010001541320000024/42010001541320000024", code);
|
|
|
+// }
|
|
|
}
|
|
|
return 1;
|
|
|
});
|