|
@@ -30,97 +30,103 @@ import java.util.regex.Pattern;
|
|
public class CameraUtil {
|
|
public class CameraUtil {
|
|
|
|
|
|
private static String url;
|
|
private static String url;
|
|
- private static String historyUrl = "http://47.106.159.135/streams";
|
|
|
|
|
|
+ private static String historyUrl;
|
|
private static String ffmpegPath;
|
|
private static String ffmpegPath;
|
|
- private static String systemUrl;
|
|
|
|
private static String mappingUrl;
|
|
private static String mappingUrl;
|
|
@Autowired
|
|
@Autowired
|
|
private CaneraConfig caneraConfig;
|
|
private CaneraConfig caneraConfig;
|
|
- @Autowired
|
|
|
|
- private ServerConfig serverConfig;
|
|
|
|
-
|
|
|
|
- public static String getPlayFlv(String cameraCode, String channel) {
|
|
|
|
- return historyUrl + "/hdl/" + channel + "/" + cameraCode + ".flv";
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 实时播放
|
|
|
|
|
|
+ * 历史回放
|
|
*
|
|
*
|
|
- * @param cameraCode
|
|
|
|
* @param channel
|
|
* @param channel
|
|
|
|
+ * @param startTm
|
|
|
|
+ * @param endTm
|
|
* @return
|
|
* @return
|
|
|
|
+ * @throws IOException
|
|
*/
|
|
*/
|
|
- public static String play(String cameraCode, String channel) {
|
|
|
|
- if (StringUtils.isBlank(cameraCode) || StringUtils.isBlank(channel)) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- String param = "id=" + cameraCode + "&channel=" + channel;
|
|
|
|
- return HttpUtils.sendGet(url + "/gb28181/api/records", param);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static List<String> historyPlayList(String channel, Date startTm, Date endTm) {
|
|
|
|
|
|
+ public static String historyPlay(String channel, Date startTm, Date endTm) throws IOException {
|
|
if (StringUtils.isBlank(channel)
|
|
if (StringUtils.isBlank(channel)
|
|
|| ObjectUtils.isEmpty(startTm)
|
|
|| ObjectUtils.isEmpty(startTm)
|
|
|| ObjectUtils.isEmpty(endTm)) {
|
|
|| ObjectUtils.isEmpty(endTm)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- List<String> ls = new ArrayList<>();
|
|
|
|
// 调用视频服务返回参数
|
|
// 调用视频服务返回参数
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
|
|
+
|
|
// 视频拼接
|
|
// 视频拼接
|
|
if (!StringUtils.isBlank(s)) {
|
|
if (!StringUtils.isBlank(s)) {
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
|
|
+ // 视频服务映射路径
|
|
|
|
+ String NewfilePath = BaseConfig.getProfile() + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
|
|
+ List<String> fromVideoFileList = new ArrayList();
|
|
for (Map<String, Object> map : maps) {
|
|
for (Map<String, Object> map : maps) {
|
|
Object path = map.get("Path");
|
|
Object path = map.get("Path");
|
|
if (!ObjectUtils.isEmpty(path)) {
|
|
if (!ObjectUtils.isEmpty(path)) {
|
|
- ls.add(mappingUrl + path.toString());
|
|
|
|
|
|
+ fromVideoFileList.add(mappingUrl + path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ convetor(fromVideoFileList, NewfilePath);
|
|
|
|
+ return null;
|
|
|
|
+// return systemUrl + "/profile" + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
}
|
|
}
|
|
- return ls;
|
|
|
|
|
|
+ // http://47.106.159.135/record/flv/34020000001320000002/20230304_183122_183222-d98df13f-ba77-11ed-aeb9-00163e06a5f3.flv
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getPlayFlv(String cameraCode, String channel) {
|
|
|
|
+ return historyUrl + "/hdl/" + channel + "/" + cameraCode + ".flv";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 历史回放
|
|
|
|
|
|
+ * 实时播放
|
|
*
|
|
*
|
|
|
|
+ * @param cameraCode
|
|
* @param channel
|
|
* @param channel
|
|
- * @param startTm
|
|
|
|
- * @param endTm
|
|
|
|
* @return
|
|
* @return
|
|
- * @throws IOException
|
|
|
|
*/
|
|
*/
|
|
- public static String historyPlay(String channel, Date startTm, Date endTm) throws IOException {
|
|
|
|
|
|
+ public static String play(String cameraCode, String channel) {
|
|
|
|
+ if (StringUtils.isBlank(cameraCode) || StringUtils.isBlank(channel)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String param = "id=" + cameraCode + "&channel=" + channel;
|
|
|
|
+ return HttpUtils.sendGet(url + "/gb28181/api/records", param);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static List<String> historyPlayList(String channel, Date startTm, Date endTm) {
|
|
if (StringUtils.isBlank(channel)
|
|
if (StringUtils.isBlank(channel)
|
|
|| ObjectUtils.isEmpty(startTm)
|
|
|| ObjectUtils.isEmpty(startTm)
|
|
|| ObjectUtils.isEmpty(endTm)) {
|
|
|| ObjectUtils.isEmpty(endTm)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+ List<String> ls = new ArrayList<>();
|
|
// 调用视频服务返回参数
|
|
// 调用视频服务返回参数
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
-
|
|
|
|
// 视频拼接
|
|
// 视频拼接
|
|
if (!StringUtils.isBlank(s)) {
|
|
if (!StringUtils.isBlank(s)) {
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
- // 视频服务映射路径
|
|
|
|
- String NewfilePath = BaseConfig.getProfile() + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
|
|
- List<String> fromVideoFileList = new ArrayList();
|
|
|
|
for (Map<String, Object> map : maps) {
|
|
for (Map<String, Object> map : maps) {
|
|
Object path = map.get("Path");
|
|
Object path = map.get("Path");
|
|
if (!ObjectUtils.isEmpty(path)) {
|
|
if (!ObjectUtils.isEmpty(path)) {
|
|
- fromVideoFileList.add(mappingUrl + path);
|
|
|
|
|
|
+ ls.add(mappingUrl + path.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- convetor(fromVideoFileList, NewfilePath);
|
|
|
|
- return systemUrl + "/profile" + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
|
|
}
|
|
}
|
|
- // http://47.106.159.135/record/flv/34020000001320000002/20230304_183122_183222-d98df13f-ba77-11ed-aeb9-00163e06a5f3.flv
|
|
|
|
- return null;
|
|
|
|
|
|
+ return ls;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostConstruct
|
|
|
|
+ public void init() {
|
|
|
|
+ url = caneraConfig.getUrl();
|
|
|
|
+ mappingUrl = caneraConfig.getMappingUrl();
|
|
|
|
+ historyUrl = caneraConfig.getHistoryUrl();
|
|
|
|
+ ffmpegPath = caneraConfig.getFfmpegPath();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -241,31 +247,5 @@ public class CameraUtil {
|
|
System.out.println(s);
|
|
System.out.println(s);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws IOException {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// historyPlay("34020000001320000002", "2023-03-03", "2023-03-04");
|
|
|
|
-// String s = "record/flv/34020000001320000002/20230304_211304_211404-70a2dff9-ba8e-11ed-aeb9-00163e06a5f3.flv";
|
|
|
|
-// int i = s.lastIndexOf("/");
|
|
|
|
-// String substring = s.substring(i + 1, s.length());
|
|
|
|
-// String substring1 = substring.substring(0, substring.indexOf("-"));
|
|
|
|
-// String[] s1 = substring1.split("_");
|
|
|
|
-// System.out.println(s1.length);
|
|
|
|
-// for (String s2 : s1) {
|
|
|
|
-// System.out.println(s2);
|
|
|
|
-// }
|
|
|
|
-// Date backupTime=DateUtils.addDays(new Date(), -1);
|
|
|
|
-// queryRecords("34020000001320000002","34020000001320000002",backupTime,DateUtils.getNowDate());
|
|
|
|
- System.out.println(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @PostConstruct
|
|
|
|
- public void init() {
|
|
|
|
- url = caneraConfig.getUrl();
|
|
|
|
- mappingUrl = caneraConfig.getMappingUrl();
|
|
|
|
- historyUrl = caneraConfig.getHistoryUrl();
|
|
|
|
- ffmpegPath = caneraConfig.getFfmpegPath();
|
|
|
|
- systemUrl = serverConfig.getUrl();
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|