Compare commits
No commits in common. "4cb2c1c4684205daea28c0a88e6a8b442d596f27" and "613d6d3dc5ae9644959248fc650b45f57eb3e482" have entirely different histories.
4cb2c1c468
...
613d6d3dc5
|
|
@ -0,0 +1,59 @@
|
|||
2025-04-19 13:21:49.922 [main] INFO com.tuoheng.steam.StreamApplication - Starting StreamApplication using Java 11.0.25 on sunpengdeMacBook-Pro.local with PID 12739 (/Users/sunpeng/workspace/ideaproject/stream_server/target/classes started by sunpeng in /Users/sunpeng/workspace/ideaproject/stream_server)
|
||||
2025-04-19 13:21:49.923 [main] INFO com.tuoheng.steam.StreamApplication - No active profile set, falling back to 1 default profile: "default"
|
||||
2025-04-19 13:21:50.252 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9011 (http)
|
||||
2025-04-19 13:21:50.255 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:21:50.255 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
|
||||
2025-04-19 13:21:50.255 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.83]
|
||||
2025-04-19 13:21:50.290 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
|
||||
2025-04-19 13:21:50.291 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 350 ms
|
||||
2025-04-19 13:21:50.447 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:21:50.465 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 9011 (http) with context path ''
|
||||
2025-04-19 13:21:50.472 [main] INFO com.tuoheng.steam.StreamApplication - Started StreamApplication in 0.757 seconds (JVM running for 1.236)
|
||||
2025-04-19 13:21:56.475 [scheduling-1] INFO com.tuoheng.steam.schedule.Scheduler - 舱内外无需录制
|
||||
2025-04-19 13:22:21.580 [main] INFO com.tuoheng.steam.StreamApplication - Starting StreamApplication using Java 11.0.25 on sunpengdeMacBook-Pro.local with PID 12750 (/Users/sunpeng/workspace/ideaproject/stream_server/target/classes started by sunpeng in /Users/sunpeng/workspace/ideaproject/stream_server)
|
||||
2025-04-19 13:22:21.581 [main] INFO com.tuoheng.steam.StreamApplication - No active profile set, falling back to 1 default profile: "default"
|
||||
2025-04-19 13:22:21.909 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9011 (http)
|
||||
2025-04-19 13:22:21.912 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:22:21.913 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
|
||||
2025-04-19 13:22:21.913 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.83]
|
||||
2025-04-19 13:22:21.953 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
|
||||
2025-04-19 13:22:21.953 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 354 ms
|
||||
2025-04-19 13:22:22.115 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:22:22.132 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 9011 (http) with context path ''
|
||||
2025-04-19 13:22:22.140 [main] INFO com.tuoheng.steam.StreamApplication - Started StreamApplication in 0.767 seconds (JVM running for 1.254)
|
||||
2025-04-19 13:22:28.140 [scheduling-1] INFO com.tuoheng.steam.schedule.Scheduler - 舱内外无需录制
|
||||
2025-04-19 13:30:19.451 [main] INFO com.tuoheng.steam.StreamApplication - Starting StreamApplication using Java 11.0.25 on sunpengdeMacBook-Pro.local with PID 12998 (/Users/sunpeng/workspace/ideaproject/stream_server/target/classes started by sunpeng in /Users/sunpeng/workspace/ideaproject/stream_server)
|
||||
2025-04-19 13:30:19.452 [main] INFO com.tuoheng.steam.StreamApplication - No active profile set, falling back to 1 default profile: "default"
|
||||
2025-04-19 13:30:19.790 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9011 (http)
|
||||
2025-04-19 13:30:19.794 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:30:19.794 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
|
||||
2025-04-19 13:30:19.794 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.83]
|
||||
2025-04-19 13:30:19.832 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
|
||||
2025-04-19 13:30:19.832 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 361 ms
|
||||
2025-04-19 13:30:19.990 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 13:30:20.008 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 9011 (http) with context path ''
|
||||
2025-04-19 13:30:20.015 [main] INFO com.tuoheng.steam.StreamApplication - Started StreamApplication in 0.768 seconds (JVM running for 1.252)
|
||||
2025-04-19 13:30:26.018 [scheduling-1] INFO com.tuoheng.steam.schedule.Scheduler - 舱内外无需录制
|
||||
2025-04-19 14:05:16.707 [main] INFO com.tuoheng.steam.StreamApplication - Starting StreamApplication using Java 11.0.25 on sunpengdeMacBook-Pro.local with PID 13714 (/Users/sunpeng/workspace/ideaproject/stream_server/target/classes started by sunpeng in /Users/sunpeng/workspace/ideaproject/stream_server)
|
||||
2025-04-19 14:05:16.709 [main] INFO com.tuoheng.steam.StreamApplication - No active profile set, falling back to 1 default profile: "default"
|
||||
2025-04-19 14:05:17.074 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9011 (http)
|
||||
2025-04-19 14:05:17.078 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 14:05:17.078 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
|
||||
2025-04-19 14:05:17.078 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.83]
|
||||
2025-04-19 14:05:17.118 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
|
||||
2025-04-19 14:05:17.118 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 389 ms
|
||||
2025-04-19 14:05:17.284 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-9011"]
|
||||
2025-04-19 14:05:17.302 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 9011 (http) with context path ''
|
||||
2025-04-19 14:05:17.310 [main] INFO com.tuoheng.steam.StreamApplication - Started StreamApplication in 0.831 seconds (JVM running for 1.34)
|
||||
2025-04-19 14:05:23.309 [scheduling-1] INFO com.tuoheng.steam.schedule.Scheduler - 舱内外无需录制
|
||||
2025-04-19 14:06:08.792 [http-nio-9011-exec-1] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
|
||||
2025-04-19 14:06:08.792 [http-nio-9011-exec-1] INFO o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
|
||||
2025-04-19 14:06:08.792 [http-nio-9011-exec-1] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 0 ms
|
||||
2025-04-19 14:06:11.948 [http-nio-9011-exec-1] INFO c.t.s.c.StreamRecordController - 启动录制 :rtmp://stream.t-aaron.com/live/livestream
|
||||
2025-04-19 14:06:11.949 [http-nio-9011-exec-1] INFO c.tuoheng.steam.service.TaskService - streamUrl rtmp://stream.t-aaron.com/live/livestream startTask 1
|
||||
2025-04-19 14:06:11.951 [http-nio-9011-exec-1] INFO c.t.s.s.innerService.ProcessService - recordStream ffmpeg -i rtmp://stream.t-aaron.com/live/livestream -c copy -f mpegts -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 2 /data/java/srs/stream_server/temp/59795526-a0eb-44ff-9fab-e0919abbbe36.ts
|
||||
2025-04-19 14:06:11.970 [http-nio-9011-exec-1] INFO c.tuoheng.steam.service.TaskService - streamUrl rtmp://stream.t-aaron.com/live/livestream taskId 1 startProcess 13724
|
||||
2025-04-19 14:06:11.995 [ForkJoinPool.commonPool-worker-19] INFO c.tuoheng.steam.service.TaskService - streamUrl rtmp://stream.t-aaron.com/live/livestream taskId 1 Process 13724 Over
|
||||
2025-04-19 14:06:11.995 [ForkJoinPool.commonPool-worker-19] INFO c.t.s.s.innerService.ProcessService - recordStream ffmpeg -i rtmp://stream.t-aaron.com/live/livestream -c copy -f mpegts -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 2 /data/java/srs/stream_server/temp/247afde2-70b3-4951-b3b0-85fd02d99045.ts
|
||||
2025-04-19 14:06:12.000 [ForkJoinPool.commonPool-worker-19] INFO c.tuoheng.steam.service.TaskService - streamUrl rtmp://stream.t-aaron.com/live/livestream taskId 1 startProcess 13725
|
||||
2025-04-19 14:06:12.023 [http-nio-9011-exec-1] INFO c.t.s.c.StreamRecordController - 启动录制返回 :{"code":200,"data":{"startTime":"2025-04-19 14:06:11.948","strStartTime":"2025-04-19 14:06:11","streamProcesses":[{"createTime":"2025-04-19 14:06:11.969","fileName":"/data/java/srs/stream_server/temp/59795526-a0eb-44ff-9fab-e0919abbbe36.ts","innerProcessId":13724,"processType":"RECORD","stopTime":"2025-04-19 14:06:11"},{"createTime":"2025-04-19 14:06:11.999","fileName":"/data/java/srs/stream_server/temp/247afde2-70b3-4951-b3b0-85fd02d99045.ts","innerProcessId":13725,"processType":"RECORD"}],"streamUrl":"rtmp://stream.t-aaron.com/live/livestream","taskId":1}}
|
||||
|
|
@ -16,7 +16,6 @@ import org.apache.logging.log4j.util.Strings;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -39,8 +38,6 @@ public class StreamRecordController {
|
|||
@GetMapping("pic")
|
||||
public Response<String> startPic(@RequestParam String streamUrl) {
|
||||
logger.info("启动视频拍照 :"+streamUrl);
|
||||
streamUrl = streamSwitch(streamUrl);
|
||||
logger.info("启动视频拍照_ :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -59,8 +56,6 @@ public class StreamRecordController {
|
|||
@GetMapping("start")
|
||||
public Response<StreamTask> startRecording(@RequestParam String streamUrl) {
|
||||
logger.info("启动录制 :"+streamUrl);
|
||||
streamUrl = streamSwitch(streamUrl);
|
||||
logger.info("启动录制_ :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -74,8 +69,6 @@ public class StreamRecordController {
|
|||
public Response<StreamTask> stopRecording(@RequestParam String streamUrl){
|
||||
|
||||
logger.info("关闭录制 :"+streamUrl);
|
||||
streamUrl = streamSwitch(streamUrl);
|
||||
logger.info("关闭录制_ :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -93,9 +86,8 @@ public class StreamRecordController {
|
|||
|
||||
@GetMapping("info")
|
||||
public Response<StreamTask> getLastTask(@RequestParam String streamUrl){
|
||||
|
||||
logger.info("查看录制 :"+streamUrl);
|
||||
streamUrl = streamSwitch(streamUrl);
|
||||
logger.info("查看录制_ :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -105,14 +97,10 @@ public class StreamRecordController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public Response<PageInfo<Mp4Info>> streamView(@RequestBody PageStreamRequest request){
|
||||
logger.info("查看录制 search :"+JSON.toJSONString(request));
|
||||
|
||||
if(Objects.isNull(request.getPageIndex()) || Objects.isNull(request.getPageSize())
|
||||
|| request.getPageIndex() <0 || request.getPageSize() <=0 ){
|
||||
logger.error("查看录制 search 入参错误!");
|
||||
|
|
@ -143,6 +131,14 @@ public class StreamRecordController {
|
|||
return Response.success(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("history")
|
||||
public Response<List<Mp4Info>> streamView(@RequestParam String streamUrl){
|
||||
logger.info("查看录像历史返回 :"+ streamUrl);
|
||||
List<Mp4Info> dayMp4 = searchAll(streamUrl);
|
||||
dayMp4.sort((o1, o2) -> o2.getStartTime().compareTo(o1.getStartTime()));
|
||||
logger.info("查看录像历史返回 :"+ JSON.toJSONString(dayMp4));
|
||||
return Response.success(dayMp4) ;
|
||||
}
|
||||
|
||||
public List<Mp4Info> searchAll(String streamUrl){
|
||||
|
||||
|
|
@ -169,60 +165,22 @@ public class StreamRecordController {
|
|||
}
|
||||
|
||||
|
||||
@Value("${srs.domain}")
|
||||
private String srsdomain;
|
||||
|
||||
@Value("${srs.name}")
|
||||
private String srsname;
|
||||
|
||||
public String streamSwitch(String source){
|
||||
|
||||
if(Objects.nonNull(srsdomain) && !srsdomain.isEmpty()){
|
||||
if(Objects.nonNull(source) && !source.isEmpty()){
|
||||
return dockerFix(source);
|
||||
/**
|
||||
* 方便测试时候使用
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("exit")
|
||||
public String exit(){
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
taskService.stopAllTask();
|
||||
Thread.sleep(10000L);
|
||||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(source.contains("stream.t-aaron.com")){
|
||||
return source;
|
||||
} else if (source.contains("rtmp://live.push.t-aaron.com")){
|
||||
source = source.replace("rtmp://live.push.t-aaron.com","http://live.play.t-aaron.com") ;
|
||||
if(source.endsWith("_")){
|
||||
source = source.substring(0,source.length()-1) + ".flv" + "_";
|
||||
}else {
|
||||
source = source + ".flv";
|
||||
}
|
||||
return source;
|
||||
}else {
|
||||
if(source.contains("https://live.play.t-aaron.com")){
|
||||
source = source.replace("https://live.play.t-aaron.com","http://live.play.t-aaron.com");
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String dockerFix(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
return url;
|
||||
}
|
||||
url = url.replaceFirst("^https?://", "rtmp://");
|
||||
// 删除末尾的 .flv
|
||||
url = url.replaceFirst("\\.flv$", "");
|
||||
|
||||
// 处理 RTMP URL
|
||||
if (url.startsWith("rtmp://")) {
|
||||
// 先删除端口号
|
||||
String withoutPort = url.replaceFirst("(rtmp://[^:/]+):\\d+", "$1");
|
||||
// 替换域名为 aaa
|
||||
String withNewDomain = withoutPort.replaceFirst("rtmp://[^/]+", "rtmp://"+srsname);
|
||||
// 删除 .flv 后缀
|
||||
return withNewDomain.replaceFirst("\\.flv$", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return url;
|
||||
System.exit(0);
|
||||
});
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.alibaba.fastjson2.JSON;
|
|||
import com.tuoheng.steam.dos.StreamProcess;
|
||||
import com.tuoheng.steam.dos.StreamTask;
|
||||
import com.tuoheng.steam.service.innerService.ProcessService;
|
||||
import com.tuoheng.steam.util.FileUtil;
|
||||
import com.tuoheng.steam.util.ProcessManager;
|
||||
import com.tuoheng.steam.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -43,7 +42,7 @@ public class TaskService implements ITaskService{
|
|||
public void cleaTask() {
|
||||
for (ConcurrentHashMap.Entry<String, StreamTask> entry : runningTasks.entrySet()) {
|
||||
StreamTask streamTask = entry.getValue();
|
||||
if(streamTask.getStartTime().getTime() < new Date().getTime() - 90 * 60 * 1000 ) {
|
||||
if(streamTask.getStartTime().getTime() < new Date().getTime() - 30 * 60 * 1000 ) {
|
||||
logger.info("清理废弃任务 {}", JSON.toJSONString(streamTask));
|
||||
try {
|
||||
StreamTask s = stopTask(entry.getKey());
|
||||
|
|
@ -109,8 +108,9 @@ public class TaskService implements ITaskService{
|
|||
for (StreamProcess process : streamProcesses) {
|
||||
process.destroy();
|
||||
File file = new File(process.getFileName());
|
||||
FileUtil.deleteFile(file);
|
||||
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,9 @@ public class TaskService implements ITaskService{
|
|||
ProcessManager.unRegisterProcess(mergeProcess.getInnerProcessId());
|
||||
for(StreamProcess streamProcess :currentStreamTask.getStreamProcesses()){
|
||||
File file = new File(streamProcess.getFileName());
|
||||
FileUtil.deleteFile(file);
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}).exceptionally(ex -> {
|
||||
logger.error("streamUrl {} taskId {} MergeProcess {} exceptionally", streamUrl,currentStreamTask.getTaskId(), mergeProcess.getInnerProcessId(), ex);
|
||||
|
|
@ -228,7 +230,9 @@ public class TaskService implements ITaskService{
|
|||
ProcessManager.unRegisterProcess(mergeProcess.getInnerProcessId());
|
||||
for(StreamProcess streamProcess :currentStreamTask.getStreamProcesses()){
|
||||
File file = new File(streamProcess.getFileName());
|
||||
FileUtil.deleteFile(file);
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
|
@ -334,14 +338,8 @@ public class TaskService implements ITaskService{
|
|||
future.thenRun(() -> {
|
||||
logger.info("streamUrl {} taskId {} Process {} Over", streamUrl, streamTask.getTaskId(),streamProcess.getInnerProcessId());
|
||||
streamProcess.setStopTime(TimeUtils.formatDateToString(new Date()));
|
||||
ProcessManager.unRegisterProcess(streamProcess.getInnerProcessId());
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (Exception ignored){}
|
||||
if(!new File(streamProcess.getFileName()).exists()){
|
||||
streamTask.getStreamProcesses().remove(streamProcess);
|
||||
}
|
||||
startTask(streamUrl, streamTask);
|
||||
ProcessManager.unRegisterProcess(streamProcess.getInnerProcessId());
|
||||
}).exceptionally(ex -> {
|
||||
logger.info("streamUrl {} taskId {} Process {} Exceptionally", streamUrl, streamTask.getTaskId(),streamProcess.getInnerProcessId(),ex);
|
||||
streamProcess.setStopTime(TimeUtils.formatDateToString(new Date()));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.tuoheng.steam.service.innerService;
|
|||
import com.tuoheng.steam.dos.StreamProcess;
|
||||
import com.tuoheng.steam.dos.ProcessType;
|
||||
import com.tuoheng.steam.service.dos.FlvRecord;
|
||||
import com.tuoheng.steam.util.FileUtil;
|
||||
import com.tuoheng.steam.util.ProcessManager;
|
||||
import com.tuoheng.steam.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -16,7 +15,10 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
|
@ -57,7 +59,6 @@ public class ProcessService {
|
|||
loggingService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("mergeMp4 process Start {}",command);
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream()))) {
|
||||
String line;
|
||||
|
|
@ -71,46 +72,24 @@ public class ProcessService {
|
|||
File delete = new File(recordPath+ File.separator +
|
||||
flvRecord.getStream().getDayRecord().getDay() + File.separator +
|
||||
flvRecord.getStream().getStreamId() + File.separator + flvRecord.getFlv());
|
||||
FileUtil.deleteFile(delete);
|
||||
if(delete.exists()){
|
||||
delete.delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CompletableFuture<Process> future = process.onExit();
|
||||
// 阻塞等待进程结束
|
||||
Process completedProcess = null;
|
||||
try {
|
||||
completedProcess = future.get(4, TimeUnit.SECONDS);
|
||||
logger.info("mergeMp4正常完成-------- Over");
|
||||
}catch (Exception e) {
|
||||
String fileName = recordPath+ File.separator +
|
||||
flvRecord.getStream().getDayRecord().getDay() + File.separator +
|
||||
flvRecord.getStream().getStreamId() + File.separator +flvRecord.getStartTime() + ".mp4";
|
||||
File file = new File(fileName);
|
||||
if(file.exists()){
|
||||
logger.info("mergeMp4超时4S完成-------- Over",e);
|
||||
process.destroy();
|
||||
} else {
|
||||
try {
|
||||
completedProcess = future.get(4, TimeUnit.SECONDS);
|
||||
}catch (Exception e1) {
|
||||
if(file.exists()){
|
||||
logger.info("mergeMp4超时8S完成-------- Over",e);
|
||||
process.destroy();
|
||||
}else {
|
||||
logger.info("mergeMp4超时8S未完成-------- Over",e);
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Process completedProcess = future.get();
|
||||
|
||||
if(Objects.nonNull(completedProcess)) {
|
||||
// 检查进程是否成功结束
|
||||
if (completedProcess.exitValue() == 0) {
|
||||
logger.info("进程成功结束!");
|
||||
} else {
|
||||
logger.info("进程失败,退出码 {} " ,completedProcess.exitValue());
|
||||
}
|
||||
// 检查进程是否成功结束
|
||||
if (completedProcess.exitValue() == 0) {
|
||||
logger.info("进程成功结束!");
|
||||
/**
|
||||
* 删除数据
|
||||
*/
|
||||
} else {
|
||||
logger.info("进程失败,退出码 {} " ,completedProcess.exitValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,23 +13,12 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
|
||||
|
||||
private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(4);
|
||||
|
||||
public static void deleteFile(File file) {
|
||||
if(file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFolder(String stringPath) {
|
||||
|
||||
try {
|
||||
|
|
@ -48,8 +37,8 @@ public class FileUtil {
|
|||
} else {
|
||||
logger.info("文件夹不存在: " + path);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("deleteFolder",e);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -69,7 +58,11 @@ public class FileUtil {
|
|||
for (File file : files) {
|
||||
list.add(file.getName());
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,20 +7,16 @@
|
|||
#recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record
|
||||
#livedates=8
|
||||
#cangneiwai=false
|
||||
#srs.domain = ""
|
||||
#srs.name = ""
|
||||
|
||||
#大数据局
|
||||
#spring.application.name=stream_server
|
||||
#server.port = 8989
|
||||
#srs.splitPath=/data/java/srs/stream_server/temp
|
||||
#srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html/recording
|
||||
#ffmpeg=ffmpeg
|
||||
#recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record
|
||||
#livedates=8
|
||||
#cangneiwai=true
|
||||
#srs.domain = ""
|
||||
#srs.name = ""
|
||||
spring.application.name=stream_server
|
||||
server.port = 8989
|
||||
srs.splitPath=/data/java/srs/stream_server/temp
|
||||
srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html
|
||||
ffmpeg=ffmpeg
|
||||
recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record
|
||||
livedates=8
|
||||
cangneiwai=true
|
||||
|
||||
#本地测试
|
||||
#spring.application.name=stream_server
|
||||
|
|
@ -29,24 +25,4 @@
|
|||
#srs.targetPath=/Users/sunpeng/workspace/stream/html
|
||||
#ffmpeg=ffmpeg
|
||||
#recordPath=/Users/sunpeng/workspace/stream/record
|
||||
#livedates=7
|
||||
#cangneiwai=false
|
||||
#srs.domain = ""
|
||||
#srs.name = ""
|
||||
|
||||
#容器化部署
|
||||
#通过注入
|
||||
srs.domain = STREAM.t-aaron.com
|
||||
#通过注入
|
||||
srs.name = STREAM
|
||||
spring.application.name=stream_server
|
||||
server.port = 8080
|
||||
#零时文件
|
||||
srs.splitPath=/data/temp
|
||||
#拍照 + 录像
|
||||
srs.targetPath=/data/recording
|
||||
ffmpeg=ffmpeg
|
||||
#
|
||||
recordPath=/data/record
|
||||
livedates=8
|
||||
cangneiwai=false
|
||||
#livedates=7
|
||||
Loading…
Reference in New Issue