This commit is contained in:
parent
95263673f9
commit
889a978bbe
|
|
@ -5,14 +5,15 @@ import com.tuoheng.steam.service.dos.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频回放服务
|
||||||
|
*/
|
||||||
public interface IRecordService {
|
public interface IRecordService {
|
||||||
|
|
||||||
public List<DayRecord> findDaysPath();
|
public List<DayRecord> findDaysPath();
|
||||||
|
|
||||||
public List<StreamRecord> findInDayRecord(DayRecord dayRecord);
|
public List<StreamRecord> findInDayRecord(DayRecord dayRecord);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void mergeMp4(FlvRecord flvRecord);
|
public void mergeMp4(FlvRecord flvRecord);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ package com.tuoheng.steam.service;
|
||||||
|
|
||||||
import com.tuoheng.steam.dos.StreamTask;
|
import com.tuoheng.steam.dos.StreamTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频录制服务
|
||||||
|
*/
|
||||||
public interface ITaskService {
|
public interface ITaskService {
|
||||||
|
|
||||||
public StreamTask startTask(String streamUrl);
|
public StreamTask startTask(String streamUrl);
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
@ -143,9 +140,15 @@ public class ProcessService {
|
||||||
public StreamProcess recordStream(String streamUrl) throws IOException {
|
public StreamProcess recordStream(String streamUrl) throws IOException {
|
||||||
|
|
||||||
String recordFileName = splitPath+'/'+UUID.randomUUID().toString() +".ts";
|
String recordFileName = splitPath+'/'+UUID.randomUUID().toString() +".ts";
|
||||||
|
/**
|
||||||
|
* 如果streamUrl末尾有个_,在实际录制的时候需要将_去除
|
||||||
|
*/
|
||||||
String command = String.format(
|
String command = String.format(
|
||||||
ffmpeg+ " -i %s -c copy -f mpegts -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 2 %s",
|
ffmpeg+ " -i %s -c copy -f mpegts -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 2 %s",
|
||||||
streamUrl, recordFileName);
|
Optional.of(streamUrl)
|
||||||
|
.filter(s -> s.endsWith("_"))
|
||||||
|
.map(s -> s.substring(0, s.length() - 1))
|
||||||
|
.orElse(streamUrl), recordFileName);
|
||||||
logger.info("recordStream {}", command);
|
logger.info("recordStream {}", command);
|
||||||
ProcessBuilder pb = new ProcessBuilder(command.split(" "));
|
ProcessBuilder pb = new ProcessBuilder(command.split(" "));
|
||||||
pb.redirectErrorStream(true);
|
pb.redirectErrorStream(true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue