|
@@ -257,39 +257,39 @@ 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);
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
public static String invite(String cameraCode, String channel) {
|
|
@@ -938,35 +938,37 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
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");
|
|
|
-// log.info("--------------->code::" + code);
|
|
|
-
|
|
|
- String streamUrl = "rtsp://124.70.58.209:8554/"+code+"/"+code;;
|
|
|
- String FilePath = "/opt/streams/map/"+code+".mp4";
|
|
|
- Process process = rtspToMP4.StartRecord(ffmpegPath, streamUrl, FilePath);
|
|
|
- log.info("------playbackURLs----->>>>:"+process);
|
|
|
- if (null != process) {
|
|
|
- map.put(code, process);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ String streamUrl = "rtsp://124.70.58.209:8554/" + code + "/" + code;
|
|
|
+ ;
|
|
|
+ String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
+ Process process = rtspToMP4.StartRecord(ffmpegPath, streamUrl, FilePath);
|
|
|
+ log.info("------playbackURLs----->>>>:" + process);
|
|
|
+ if (null != process) {
|
|
|
+ map.put(code, process);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return 1;
|