|
@@ -2,6 +2,7 @@ package com.example.unusualsounds.project.vox.config;
|
|
|
|
|
|
import com.example.unusualsounds.common.utils.FileToMultipartFile;
|
|
|
import com.example.unusualsounds.common.utils.RedisUtils;
|
|
|
+import com.example.unusualsounds.common.utils.VoiceAnalysisUtils;
|
|
|
import com.example.unusualsounds.framework.minio.MinioUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
@@ -39,8 +40,6 @@ public class VideoTaskManager {
|
|
|
@Autowired
|
|
|
private MinioUtil minioUtil;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RestTemplate restTemplate;
|
|
|
|
|
|
private final ConcurrentMap<String, VideoTask> taskMap = new ConcurrentHashMap<>();
|
|
|
|
|
@@ -92,7 +91,6 @@ public class VideoTaskManager {
|
|
|
|
|
|
@Data
|
|
|
private class VideoTask {
|
|
|
- //streamId = streamId+ skillName
|
|
|
private final String streamId;
|
|
|
private final String rtspUrl;
|
|
|
private String skillName;
|
|
@@ -113,13 +111,14 @@ public class VideoTaskManager {
|
|
|
|
|
|
void start() {
|
|
|
List<String> command = Arrays.asList(
|
|
|
- "D:\\file\\ffmpeg\\ffmpeg.exe",
|
|
|
+// "D:\\file\\ffmpeg\\ffmpeg.exe",
|
|
|
+ "ffmpeg",
|
|
|
"-rtsp_transport", "tcp",
|
|
|
"-i", rtspUrl,
|
|
|
"-vn",
|
|
|
"-c", "copy",
|
|
|
"-f", "segment",
|
|
|
- "-segment_time", "100",
|
|
|
+ "-segment_time", "300", //100秒
|
|
|
"-segment_format", "mp4",
|
|
|
"-reset_timestamps", "1",
|
|
|
"-force_key_frames", "expr:gte(t,n_floor(t/100)*100)",
|
|
@@ -127,7 +126,6 @@ public class VideoTaskManager {
|
|
|
"-segment_atclocktime", "1",
|
|
|
"-strftime", "1",
|
|
|
videoDir+streamId+"-%Y-%m-%d_%H-%M-%S"+".mp4"
|
|
|
-// "D:\\tmp\\data\\vox\\"+streamId+".mp4"
|
|
|
);
|
|
|
|
|
|
ProcessBuilder pb = new ProcessBuilder(command)
|
|
@@ -225,7 +223,8 @@ public class VideoTaskManager {
|
|
|
while (true){
|
|
|
//检查文件是否完成
|
|
|
List<String> checkVoxFinish = Arrays.asList(
|
|
|
- "D:\\file\\ffmpeg\\ffmpeg.exe",
|
|
|
+// "D:\\file\\ffmpeg\\ffmpeg.exe",
|
|
|
+ "ffmpeg",
|
|
|
"-v","error",
|
|
|
"-i", filePath,
|
|
|
"-f", "null",
|
|
@@ -244,8 +243,8 @@ public class VideoTaskManager {
|
|
|
log.error("checkVoxFinish:[{}]文件未完成",filePath);
|
|
|
//重置状态errorOutput状态
|
|
|
errorOutput.delete(0, errorOutput.length());
|
|
|
- //等待1分钟后再次检查
|
|
|
- Thread.sleep(60000);
|
|
|
+ //等待2分钟后再次检查
|
|
|
+ Thread.sleep(120000);
|
|
|
}else {
|
|
|
//上传文件
|
|
|
File file = new File(filePath);
|
|
@@ -255,22 +254,13 @@ public class VideoTaskManager {
|
|
|
log.info("上传文件:{}",upload);
|
|
|
|
|
|
//发送消息
|
|
|
- HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
- hashMap.put("filePath",upload);
|
|
|
- hashMap.put("skillName",skillName);
|
|
|
- hashMap.put("streamId",streamId);
|
|
|
- hashMap.put("deviceName",deviceName);
|
|
|
- hashMap.put("skillId",skillId);
|
|
|
-
|
|
|
-
|
|
|
- HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
- httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- HttpEntity<Map<String, Object>> mapHttpEntity = new HttpEntity<Map<String, Object>>(hashMap, httpHeaders);
|
|
|
- ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(postAnalysisUrl, mapHttpEntity, String.class);
|
|
|
- if (stringResponseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
- log.info("通知算法成功");
|
|
|
- }
|
|
|
-
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("filePath",upload);
|
|
|
+ map.put("skillName",skillName);
|
|
|
+ map.put("streamId",streamId);
|
|
|
+ map.put("deviceName",deviceName);
|
|
|
+ map.put("skillId",skillId);
|
|
|
+ log.info(VoiceAnalysisUtils.postVoxAnalysis(map, postAnalysisUrl));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -281,8 +271,6 @@ public class VideoTaskManager {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|