|
@@ -241,10 +241,10 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @param channel 相机通道
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String getPlayFlv(String cameraCode, String channel, boolean flay,String state) {
|
|
|
+ public static String getPlayFlv(String cameraCode, String channel, boolean flay, String state) {
|
|
|
if (state.contains("master")) {
|
|
|
return wsUrl + "/ws/" + cameraCode + "/" + channel + ".flv";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return wsUrls + "/ws/" + cameraCode + "/" + channel + ".flv";
|
|
|
}
|
|
|
|
|
@@ -276,7 +276,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @param channel 相机通道
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String getPlayFlvRtsp(String cameraCode, String channel, boolean flay,String state) {
|
|
|
+ public static String getPlayFlvRtsp(String cameraCode, String channel, boolean flay, String state) {
|
|
|
if (state.contains("master")) {
|
|
|
log.info("-----getPlayFlvRtsp------11------>" + bakUrlRtsp + "/master/hdl/" + cameraCode + "/" + channel + ".flv");
|
|
|
return bakUrlRtsp + "/master/hdl/" + cameraCode + "/" + channel + "/h264_720.flv";
|
|
@@ -321,7 +321,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @param channel
|
|
|
* @return
|
|
|
*/
|
|
|
- public String getPlayFlv(String cameraCode, String channel) {
|
|
|
+ public String getPlayFlv(String cameraCode, String channel) {
|
|
|
int maxRetries = 3;
|
|
|
int retryCount = 0;
|
|
|
boolean success = false;
|
|
@@ -351,7 +351,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
boolean contains = pathList.contains(cameraCode + "/" + channel);
|
|
|
if (contains) {
|
|
|
String cacheObject = redisCache.getCacheObject(cameraCode);
|
|
|
- return getPlayFlv(cameraCode, channel, true,cacheObject);
|
|
|
+ return getPlayFlv(cameraCode, channel, true, cacheObject);
|
|
|
} else {
|
|
|
/**
|
|
|
* jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
@@ -362,23 +362,33 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
*/
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
|
- previewURLs(camerasVo, channel);
|
|
|
- String cacheObject = redisCache.getCacheObject(cameraCode);
|
|
|
- return getPlayFlv(cameraCode, channel, true,cacheObject);
|
|
|
+ String urLs = previewURLs(camerasVo, channel);
|
|
|
+ if (!urLs.contains("无视频")) {
|
|
|
+ return getPlayFlv(cameraCode, channel, true, urLs);
|
|
|
+ }else {
|
|
|
+ return urLs;
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
|
- previewURLs(camerasVo, channel);
|
|
|
- String cacheObject = redisCache.getCacheObject(cameraCode);
|
|
|
- return getPlayFlv(cameraCode, channel, true,cacheObject);
|
|
|
+ String urLs = previewURLs(camerasVo, channel);
|
|
|
+ if (!urLs.contains("无视频")) {
|
|
|
+ return getPlayFlv(cameraCode, channel, true, urLs);
|
|
|
+ }else {
|
|
|
+ return urLs;
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
|
previewURLs(camerasVo, channel);
|
|
|
- String cacheObject = redisCache.getCacheObject(cameraCode);
|
|
|
- return getPlayFlv(cameraCode, channel, true,cacheObject);
|
|
|
+ String urLs = previewURLs(camerasVo, channel);
|
|
|
+ if (!urLs.contains("无视频")) {
|
|
|
+ return getPlayFlv(cameraCode, channel, true, urLs);
|
|
|
+ }else {
|
|
|
+ return urLs;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -414,7 +424,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return null;
|
|
|
} else {
|
|
|
String cacheObject = redisCache.getCacheObject(cameraCode);
|
|
|
- return getPlayFlvRtsp(cameraCode, channel, type,cacheObject);
|
|
|
+ return getPlayFlvRtsp(cameraCode, channel, type, cacheObject);
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -449,9 +459,9 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
log.info("-------无视频---------");
|
|
|
return s;
|
|
|
} else {
|
|
|
- log.info("-------getPlayFlvRtsp---------" + getPlayFlvRtsp(cameraCode, channel, type,s));
|
|
|
- redisCache.setCacheObject(cameraCode, s,2000,TimeUnit.SECONDS);
|
|
|
- return getPlayFlvRtsp(cameraCode, channel, type,s);
|
|
|
+ log.info("-------getPlayFlvRtsp---------" + getPlayFlvRtsp(cameraCode, channel, type, s));
|
|
|
+ redisCache.setCacheObject(cameraCode, s, 2000, TimeUnit.SECONDS);
|
|
|
+ return getPlayFlvRtsp(cameraCode, channel, type, s);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -925,7 +935,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return getPlayFlv(code, channel, true,"master");
|
|
|
+ return getPlayFlv(code, channel, true, "master");
|
|
|
} else {
|
|
|
return "调用天网接口失败";
|
|
|
}
|
|
@@ -1258,7 +1268,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return "暂无视频-" + camerasVo.getCameraIndexCode();
|
|
|
}
|
|
|
return "master";
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (urlCounts * 2 > urlCount) {
|
|
|
log.info("httpUrl---------->" + httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
@@ -1268,7 +1278,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return "暂无视频-" + camerasVo.getCameraIndexCode();
|
|
|
}
|
|
|
return "master";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
log.info("httpUrl---------->" + httpUrls + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
String msg = HttpUtils.sendGet(httpUrls + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
|
|
|
log.info("msg---------->" + msg);
|
|
@@ -1660,15 +1670,15 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(streamArray)) {
|
|
|
- for (int i = 0; i < streamArray.size(); i++) {
|
|
|
- JSONObject subObj = streamArray.getJSONObject(i);
|
|
|
- String PathValue = subObj.getString("Path");
|
|
|
- if (PathValue.contains("/h264_720")) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- return count;
|
|
|
- }else {
|
|
|
+// for (int i = 0; i < streamArray.size(); i++) {
|
|
|
+// JSONObject subObj = streamArray.getJSONObject(i);
|
|
|
+// String PathValue = subObj.getString("Path");
|
|
|
+// if (PathValue.contains("/h264_720")) {
|
|
|
+// count++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ return streamArray.size();
|
|
|
+ } else {
|
|
|
return count;
|
|
|
}
|
|
|
}
|