This commit is contained in:
parent
03a23330bb
commit
e692d319c3
59
logs/app.log
59
logs/app.log
|
|
@ -1,59 +0,0 @@
|
|||
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}}
|
||||
|
|
@ -37,6 +37,8 @@ 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);
|
||||
|
|
@ -55,6 +57,8 @@ 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);
|
||||
|
|
@ -68,6 +72,8 @@ public class StreamRecordController {
|
|||
@GetMapping("stop")
|
||||
public Response<StreamTask> stopRecording(@RequestParam String streamUrl){
|
||||
|
||||
logger.info("关闭录制 :"+streamUrl);
|
||||
streamUrl = streamSwitch(streamUrl);
|
||||
logger.info("关闭录制 :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
|
|
@ -86,7 +92,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);
|
||||
|
|
@ -97,10 +104,14 @@ 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 入参错误!");
|
||||
|
|
@ -131,6 +142,11 @@ public class StreamRecordController {
|
|||
return Response.success(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
* @param streamUrl
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("history")
|
||||
public Response<List<Mp4Info>> streamView(@RequestParam String streamUrl){
|
||||
logger.info("查看录像历史返回 :"+ streamUrl);
|
||||
|
|
@ -183,4 +199,22 @@ public class StreamRecordController {
|
|||
});
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public String streamSwitch(String source){
|
||||
|
||||
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","https://live.play.t-aaron.com") ;
|
||||
if(source.endsWith("_")){
|
||||
source = source.substring(0,source.length()-1) + ".flv" + "_";
|
||||
}else {
|
||||
source = source + ".flv";
|
||||
}
|
||||
return source;
|
||||
}else {
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
|
@ -108,9 +109,8 @@ public class TaskService implements ITaskService{
|
|||
for (StreamProcess process : streamProcesses) {
|
||||
process.destroy();
|
||||
File file = new File(process.getFileName());
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
FileUtil.deleteFile(file);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,9 +220,7 @@ public class TaskService implements ITaskService{
|
|||
ProcessManager.unRegisterProcess(mergeProcess.getInnerProcessId());
|
||||
for(StreamProcess streamProcess :currentStreamTask.getStreamProcesses()){
|
||||
File file = new File(streamProcess.getFileName());
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
FileUtil.deleteFile(file);
|
||||
}
|
||||
}).exceptionally(ex -> {
|
||||
logger.error("streamUrl {} taskId {} MergeProcess {} exceptionally", streamUrl,currentStreamTask.getTaskId(), mergeProcess.getInnerProcessId(), ex);
|
||||
|
|
@ -230,9 +228,7 @@ public class TaskService implements ITaskService{
|
|||
ProcessManager.unRegisterProcess(mergeProcess.getInnerProcessId());
|
||||
for(StreamProcess streamProcess :currentStreamTask.getStreamProcesses()){
|
||||
File file = new File(streamProcess.getFileName());
|
||||
if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
FileUtil.deleteFile(file);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
|
@ -338,8 +334,14 @@ public class TaskService implements ITaskService{
|
|||
future.thenRun(() -> {
|
||||
logger.info("streamUrl {} taskId {} Process {} Over", streamUrl, streamTask.getTaskId(),streamProcess.getInnerProcessId());
|
||||
streamProcess.setStopTime(TimeUtils.formatDateToString(new Date()));
|
||||
startTask(streamUrl, streamTask);
|
||||
ProcessManager.unRegisterProcess(streamProcess.getInnerProcessId());
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (Exception ignored){}
|
||||
if(!new File(streamProcess.getFileName()).exists()){
|
||||
streamTask.getStreamProcesses().remove(streamProcess);
|
||||
}
|
||||
startTask(streamUrl, streamTask);
|
||||
}).exceptionally(ex -> {
|
||||
logger.info("streamUrl {} taskId {} Process {} Exceptionally", streamUrl, streamTask.getTaskId(),streamProcess.getInnerProcessId(),ex);
|
||||
streamProcess.setStopTime(TimeUtils.formatDateToString(new Date()));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
|
@ -72,9 +73,7 @@ public class ProcessService {
|
|||
File delete = new File(recordPath+ File.separator +
|
||||
flvRecord.getStream().getDayRecord().getDay() + File.separator +
|
||||
flvRecord.getStream().getStreamId() + File.separator + flvRecord.getFlv());
|
||||
if(delete.exists()){
|
||||
delete.delete();
|
||||
}
|
||||
FileUtil.deleteFile(delete);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,23 @@ 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 {
|
||||
|
|
@ -37,8 +48,8 @@ public class FileUtil {
|
|||
} else {
|
||||
logger.info("文件夹不存在: " + path);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}catch (Exception e) {
|
||||
logger.error("deleteFolder",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -58,11 +69,7 @@ public class FileUtil {
|
|||
for (File file : files) {
|
||||
list.add(file.getName());
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
#公司环境
|
||||
spring.application.name=stream_server
|
||||
server.port = 9011
|
||||
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=false
|
||||
|
||||
#大数据局
|
||||
#spring.application.name=stream_server
|
||||
#server.port = 9011
|
||||
#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=false
|
||||
|
||||
#大数据局
|
||||
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
|
||||
#cangneiwai=true
|
||||
|
||||
#本地测试
|
||||
#spring.application.name=stream_server
|
||||
|
|
@ -25,4 +25,5 @@ cangneiwai=true
|
|||
#srs.targetPath=/Users/sunpeng/workspace/stream/html
|
||||
#ffmpeg=ffmpeg
|
||||
#recordPath=/Users/sunpeng/workspace/stream/record
|
||||
#livedates=7
|
||||
#livedates=7
|
||||
#cangneiwai=false
|
||||
Loading…
Reference in New Issue