|
@@ -304,12 +304,26 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getPlayFlv(String cameraCode, String channel) {
|
|
|
+ int maxRetries = 3;
|
|
|
+ int retryCount = 0;
|
|
|
+ boolean success = false;
|
|
|
+ JSONArray jsonArray = null;
|
|
|
List<String> pathList = new ArrayList<>();
|
|
|
String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
|
|
|
if (StringUtils.isNotEmpty(data)) {
|
|
|
log.info("---------------data---" + data);
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(data);
|
|
|
- log.info("---------------jsonArray---" + jsonArray);
|
|
|
+ while (!success && retryCount < maxRetries) {
|
|
|
+ try {
|
|
|
+ jsonArray = JSONArray.parseArray(data);
|
|
|
+ success = true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("Exception caught: " + e.getMessage());
|
|
|
+ // 增加重试计数
|
|
|
+ retryCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("---------------jsonArray---" + jsonArray);
|
|
|
if (!ObjectUtils.isEmpty(jsonArray)) {
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
@@ -347,11 +361,25 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
public String heartbeatgetPlayFlv(String cameraCode, String channel, boolean type) {
|
|
|
+ int maxRetries = 3;
|
|
|
+ int retryCount = 0;
|
|
|
+ boolean success = false;
|
|
|
+ JSONArray jsonArray = null;
|
|
|
List<String> pathList = new ArrayList<>();
|
|
|
String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
|
|
|
log.info("data------------------>" + data);
|
|
|
if (StringUtils.isNotEmpty(data)) {
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(data);
|
|
|
+ while (!success && retryCount < maxRetries) {
|
|
|
+ try {
|
|
|
+ jsonArray = JSONArray.parseArray(data);
|
|
|
+ success = true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("Exception caught: " + e.getMessage());
|
|
|
+ // 增加重试计数
|
|
|
+ retryCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
log.info("jsonArray------------------>" + jsonArray);
|
|
|
if (!ObjectUtils.isEmpty(jsonArray)) {
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|