|
@@ -7,6 +7,7 @@ import com.ozs.common.exception.base.BaseException;
|
|
import com.ozs.common.utils.DateUtils;
|
|
import com.ozs.common.utils.DateUtils;
|
|
import com.ozs.common.utils.http.HttpUtils;
|
|
import com.ozs.common.utils.http.HttpUtils;
|
|
import com.ozs.web.core.config.CaneraConfig;
|
|
import com.ozs.web.core.config.CaneraConfig;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -22,6 +23,7 @@ import java.util.regex.Pattern;
|
|
* 相机工具
|
|
* 相机工具
|
|
*/
|
|
*/
|
|
@Component
|
|
@Component
|
|
|
|
+@Slf4j
|
|
public class CameraUtil {
|
|
public class CameraUtil {
|
|
|
|
|
|
private static String url;
|
|
private static String url;
|
|
@@ -43,6 +45,8 @@ public class CameraUtil {
|
|
public static String historyPlay(List<String> fromVideoFileList, String ph) throws IOException {
|
|
public static String historyPlay(List<String> fromVideoFileList, String ph) throws IOException {
|
|
// 视频服务映射路径
|
|
// 视频服务映射路径
|
|
String NewfilePath = BaseConfig.getProfile() + ph;
|
|
String NewfilePath = BaseConfig.getProfile() + ph;
|
|
|
|
+ log.info("NewfilePath:{}", NewfilePath);
|
|
|
|
+ log.info("fromVideoFileList:{}", fromVideoFileList);
|
|
convetor(fromVideoFileList, NewfilePath);
|
|
convetor(fromVideoFileList, NewfilePath);
|
|
return "/profile" + ph;
|
|
return "/profile" + ph;
|
|
}
|
|
}
|
|
@@ -67,7 +71,7 @@ public class CameraUtil {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static String historyPlayList(String channel, Date startTm, Date endTm) {
|
|
|
|
|
|
+ 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)) {
|
|
@@ -77,14 +81,14 @@ public class CameraUtil {
|
|
List<String> ls = new ArrayList<>();
|
|
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, endTm);
|
|
String ph = "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
String ph = "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
+ "/" + channel + "/" + startTime + "/" + endTime + "/"
|
|
+ "/" + channel + "/" + startTime + "/" + endTime + "/"
|
|
+ UUID.randomUUID().toString() + ".flv";
|
|
+ UUID.randomUUID().toString() + ".flv";
|
|
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) || "null".equals(s)) {
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
for (Map<String, Object> map : maps) {
|
|
for (Map<String, Object> map : maps) {
|
|
Object path = map.get("Path");
|
|
Object path = map.get("Path");
|
|
@@ -99,19 +103,19 @@ public class CameraUtil {
|
|
Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
|
|
Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
|
|
Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
|
|
Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
|
|
/* s | e | */
|
|
/* s | e | */
|
|
- if (sdate.compareTo(startTm) <= 0 && edate.compareTo(startTm) > 0) {
|
|
|
|
|
|
+ if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) > 0) {
|
|
ls.add(mappingUrl + path.toString());
|
|
ls.add(mappingUrl + path.toString());
|
|
|
|
|
|
/* | s e | */
|
|
/* | s e | */
|
|
- } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) <= 0) {
|
|
|
|
|
|
+ } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) <= 0) {
|
|
ls.add(mappingUrl + path.toString());
|
|
ls.add(mappingUrl + path.toString());
|
|
|
|
|
|
/* | s | e */
|
|
/* | s | e */
|
|
- } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) >= 0) {
|
|
|
|
|
|
+ } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) >= 0) {
|
|
ls.add(mappingUrl + path.toString());
|
|
ls.add(mappingUrl + path.toString());
|
|
|
|
|
|
/* s| | e */
|
|
/* s| | e */
|
|
- } else if (sdate.compareTo(startTm) <= 0 && edate.compareTo(endTm) >= 0) {
|
|
|
|
|
|
+ } else if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) >= 0) {
|
|
ls.add(mappingUrl + path.toString());
|
|
ls.add(mappingUrl + path.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -119,11 +123,12 @@ public class CameraUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!ObjectUtils.isEmpty(ls)) {
|
|
if (!ObjectUtils.isEmpty(ls)) {
|
|
- try {
|
|
|
|
- return historyPlay(ls, ph);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ return ls;
|
|
|
|
+// try {
|
|
|
|
+// return historyPlay(ls, ph);
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -144,6 +149,7 @@ public class CameraUtil {
|
|
*/
|
|
*/
|
|
public static void convetor(List<String> fromVideoFileList,
|
|
public static void convetor(List<String> fromVideoFileList,
|
|
String NewfilePath) throws IOException {
|
|
String NewfilePath) throws IOException {
|
|
|
|
+
|
|
new Thread(
|
|
new Thread(
|
|
() -> {
|
|
() -> {
|
|
try {
|
|
try {
|
|
@@ -255,4 +261,39 @@ public class CameraUtil {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 合并多个视频文件
|
|
|
|
+ */
|
|
|
|
+ public static void mergeFile(List<String> fromVideoFileList, String NewfilePath) {
|
|
|
|
+ // 合并命令
|
|
|
|
+ String commit = "$0 -f concat -safe 0 -i $1 -c copy $2";
|
|
|
|
+
|
|
|
|
+ String str = commit.replace("$0", ffmpegPath);
|
|
|
|
+ if (!ObjectUtils.isEmpty(fromVideoFileList)) {
|
|
|
|
+ for (String s : fromVideoFileList) {
|
|
|
|
+ str = str.replace("$1", s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ str = str.replace("$2", NewfilePath);
|
|
|
|
+ System.out.println(str);
|
|
|
|
+ Runtime runtime = Runtime.getRuntime();
|
|
|
|
+ try {
|
|
|
|
+ Process proce = runtime.exec(str);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
|
+
|
|
|
|
+ List<String> fromVideoFileList = new ArrayList();
|
|
|
|
+ String p = "C:\\Users\\Administrator.DESKTOP-0NUUTMM\\Desktop\\work\\106\\流媒体\\";
|
|
|
|
+ String NewfilePath = p + "mergevideo.flv";
|
|
|
|
+ fromVideoFileList.add(p + "20230303_174931_175031-d6d56396-b9a8-11ed-aeb9-00163e06a5f3.flv");
|
|
|
|
+ fromVideoFileList.add(p + "20230303_175032_175132-fb32b9fe-b9a8-11ed-aeb9-00163e06a5f3.flv");
|
|
|
|
+ fromVideoFileList.add(p + "20230303_175133_175233-1f97af04-b9a9-11ed-aeb9-00163e06a5f3.flv");
|
|
|
|
+ fromVideoFileList.add(p + "20230303_175234_175334-43f4daf1-b9a9-11ed-aeb9-00163e06a5f3.flv");
|
|
|
|
+ convetor(fromVideoFileList, NewfilePath);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|