This commit is contained in:
parent
d65aaaf4b6
commit
4ca3c73323
|
|
@ -37,7 +37,7 @@ public class StreamRecordController {
|
|||
|
||||
@GetMapping("pic")
|
||||
public Response<String> startPic(@RequestParam String streamUrl) {
|
||||
System.out.println("启动视频拍照 :"+streamUrl);
|
||||
logger.info("启动视频拍照 :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -55,20 +55,20 @@ public class StreamRecordController {
|
|||
|
||||
@GetMapping("start")
|
||||
public Response<StreamTask> startRecording(@RequestParam String streamUrl) {
|
||||
System.out.println("启动录制 :"+streamUrl);
|
||||
logger.info("启动录制 :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
||||
Response<StreamTask> response = Response.success(taskService.startTask(streamUrl));
|
||||
System.out.println("启动录制返回 :"+ JSON.toJSONString(response));
|
||||
logger.info("启动录制返回 :"+ JSON.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping("stop")
|
||||
public Response<StreamTask> stopRecording(@RequestParam String streamUrl){
|
||||
|
||||
System.out.println("关闭录制 :"+streamUrl);
|
||||
logger.info("关闭录制 :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ public class StreamRecordController {
|
|||
if(Objects.isNull(response.getData()) || Objects.isNull(response.getData().getOutFileName()) || response.getData().getOutFileName().isEmpty()){
|
||||
response.setCode(500);
|
||||
}
|
||||
System.out.println("关闭录制返回 :"+ JSON.toJSONString(response));
|
||||
logger.info("关闭录制返回 :"+ JSON.toJSONString(response));
|
||||
return response;
|
||||
}catch (Exception e){
|
||||
return Response.fail(-1);
|
||||
|
|
@ -87,23 +87,23 @@ public class StreamRecordController {
|
|||
@GetMapping("info")
|
||||
public Response<StreamTask> getLastTask(@RequestParam String streamUrl){
|
||||
|
||||
System.out.println("查看录制 :"+streamUrl);
|
||||
logger.info("查看录制 :"+streamUrl);
|
||||
if(Objects.isNull(streamUrl)) {
|
||||
return Response.fail(-1);
|
||||
}
|
||||
Response<StreamTask> response = Response.success(taskService.getLastTask(streamUrl));
|
||||
System.out.println("查看录制返回 :"+ JSON.toJSONString(response));
|
||||
logger.info("查看录制返回 :"+ JSON.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("search")
|
||||
public Response<PageInfo<Mp4Info>> streamView(@RequestBody PageStreamRequest request){
|
||||
System.out.println("查看录制 search :"+JSON.toJSONString(request));
|
||||
logger.info("查看录制 search :"+JSON.toJSONString(request));
|
||||
|
||||
if(Objects.isNull(request.getPageIndex()) || Objects.isNull(request.getPageSize())
|
||||
|| request.getPageIndex() <0 || request.getPageSize() <=0 ){
|
||||
System.out.println("查看录制 search 入参错误!");
|
||||
logger.error("查看录制 search 入参错误!");
|
||||
return Response.fail(-100);
|
||||
}
|
||||
|
||||
|
|
@ -127,16 +127,16 @@ public class StreamRecordController {
|
|||
*/
|
||||
mp4s.sort((o1, o2) -> o2.getStartTime().compareTo(o1.getStartTime()));
|
||||
PageInfo<Mp4Info> pageInfo = new PageInfo<>(mp4s,request.getPageIndex(),request.getPageSize());
|
||||
System.out.println("查看录制 search 返回:"+JSON.toJSONString(request));
|
||||
logger.info("查看录制 search 返回:"+JSON.toJSONString(request));
|
||||
return Response.success(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("history")
|
||||
public Response<List<Mp4Info>> streamView(@RequestParam String streamUrl){
|
||||
System.out.println("查看录像历史返回 :"+ streamUrl);
|
||||
logger.info("查看录像历史返回 :"+ streamUrl);
|
||||
List<Mp4Info> dayMp4 = searchAll(streamUrl);
|
||||
dayMp4.sort((o1, o2) -> o2.getStartTime().compareTo(o1.getStartTime()));
|
||||
System.out.println("查看录像历史返回 :"+ JSON.toJSONString(dayMp4));
|
||||
logger.info("查看录像历史返回 :"+ JSON.toJSONString(dayMp4));
|
||||
return Response.success(dayMp4) ;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,21 @@ public class Scheduler {
|
|||
@Value("${livedates}")
|
||||
private Integer livedates;
|
||||
|
||||
@Value("${cangneiwai}")
|
||||
private Boolean cangneiwai;
|
||||
/**
|
||||
* 初次执行延迟6秒执行
|
||||
* 每隔 60 分钟执行一次 60*60*1000
|
||||
*/
|
||||
@Scheduled(fixedRate = 3600000, initialDelay = 6000)
|
||||
public void mergeTask() {
|
||||
System.out.println("开始FLV到MP4的转换 - " + System.currentTimeMillis() / 1000);
|
||||
|
||||
if(!cangneiwai){
|
||||
logger.info("舱内外无需录制");
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("开始FLV到MP4的转换 - " + System.currentTimeMillis() / 1000);
|
||||
List<DayRecord> dayRecords = iRecordService.findDaysPath();
|
||||
for (int index = 0; index < dayRecords.size(); index++) {
|
||||
|
||||
|
|
|
|||
|
|
@ -248,18 +248,18 @@ public class TaskService implements ITaskService{
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("FileName :"+currentStreamTask.getMergeProcess().getFileName());
|
||||
logger.info("FileName :"+currentStreamTask.getMergeProcess().getFileName());
|
||||
Process process = Runtime.getRuntime().exec(ffmpeg + " -i " +
|
||||
currentStreamTask.getMergeProcess().getFileName());
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("Duration line: " + line);
|
||||
logger.info("Duration line: " + line);
|
||||
if (line.contains("Duration")) {
|
||||
String duration = line.split("Duration: ")[1].split(",")[0];
|
||||
System.out.println("Duration: " + duration.substring(0, 8));
|
||||
logger.info("Duration: " + duration.substring(0, 8));
|
||||
currentStreamTask.setDuration(duration.substring(0, 8));
|
||||
System.out.println("-----------------放入缓存-----------------");
|
||||
logger.info("-----------------放入缓存-----------------");
|
||||
/**
|
||||
* 放入缓存
|
||||
*/
|
||||
|
|
@ -274,7 +274,7 @@ public class TaskService implements ITaskService{
|
|||
}
|
||||
reader.close();
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
logger.info(e.getMessage());
|
||||
}
|
||||
}
|
||||
},40, TimeUnit.SECONDS);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.tuoheng.steam.util;
|
||||
|
||||
import com.tuoheng.steam.controller.StreamRecordController;
|
||||
import com.tuoheng.steam.service.dos.DayRecord;
|
||||
import com.tuoheng.steam.service.dos.StreamType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -14,6 +17,8 @@ import java.util.stream.Stream;
|
|||
|
||||
public class FileUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
|
||||
|
||||
public static void deleteFolder(String stringPath) {
|
||||
|
||||
try {
|
||||
|
|
@ -30,7 +35,7 @@ public class FileUtil {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
System.out.println("文件夹不存在: " + path);
|
||||
logger.info("文件夹不存在: " + path);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.tuoheng.steam.util;
|
||||
|
||||
import com.tuoheng.steam.controller.StreamRecordController;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -8,6 +11,8 @@ import java.util.*;
|
|||
@Service
|
||||
public class ProcessManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProcessManager.class);
|
||||
|
||||
private static final String DELIMITER = "=";
|
||||
|
||||
static Map<Long, String> runningProcessIds = new HashMap<>();
|
||||
|
|
@ -96,9 +101,9 @@ public class ProcessManager {
|
|||
int exitCode = process.waitFor();
|
||||
|
||||
if (exitCode == 0) {
|
||||
System.out.println("Process with PID " + pid + " terminated successfully.");
|
||||
logger.info("Process with PID " + pid + " terminated successfully.");
|
||||
} else {
|
||||
System.err.println("Failed to terminate process with PID " + pid + ". Exit code: " + exitCode);
|
||||
logger.error("Failed to terminate process with PID " + pid + ". Exit code: " + exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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=false
|
||||
|
||||
#大数据局
|
||||
#spring.application.name=demo
|
||||
|
|
@ -15,6 +16,7 @@ livedates=8
|
|||
#ffmpeg=ffmpeg
|
||||
#recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record
|
||||
#livedates=8
|
||||
#cangneiwai=true
|
||||
|
||||
#本地测试
|
||||
#server.port = 8080
|
||||
|
|
|
|||
Loading…
Reference in New Issue