添加结束时间
This commit is contained in:
parent
ea7bef8368
commit
a5fd6d8138
3
pom.xml
3
pom.xml
|
|
@ -52,6 +52,9 @@
|
||||||
<version>2.0.53</version>
|
<version>2.0.53</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ public class StreamTask implements Serializable {
|
||||||
Long taskId;
|
Long taskId;
|
||||||
Date startTime;
|
Date startTime;
|
||||||
String strStartTime;
|
String strStartTime;
|
||||||
|
|
||||||
|
public String getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(String duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
String duration;
|
||||||
/**
|
/**
|
||||||
* 接收到结束命令的时间
|
* 接收到结束命令的时间
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
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.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
|
|
@ -198,6 +200,31 @@ public class TaskService implements ITaskService{
|
||||||
historyTasks.get(streamUrl).offerLast(currentStreamTask);
|
historyTasks.get(streamUrl).offerLast(currentStreamTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Objects.nonNull(currentStreamTask.getMergeProcess())){
|
||||||
|
if(Objects.nonNull(currentStreamTask.getMergeProcess().getFileName()) &&
|
||||||
|
!currentStreamTask.getMergeProcess().getFileName().isEmpty()){
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("/data/ffmpeg/bin/ffmpeg -i " +
|
||||||
|
currentStreamTask.getMergeProcess().getFileName());
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (line.contains("Duration")) {
|
||||||
|
System.out.println("line: " + line);
|
||||||
|
String duration = line.split("Duration: ")[1].split(",")[0];
|
||||||
|
System.out.println("Duration: " + duration.substring(0, 8));
|
||||||
|
currentStreamTask.setDuration(duration.substring(0, 8));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return currentStreamTask;
|
return currentStreamTask;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("taskId {} Stop exceptionally", streamUrl,e);
|
logger.info("taskId {} Stop exceptionally", streamUrl,e);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
spring.application.name=demo
|
spring.application.name=demo
|
||||||
server.port = 9011
|
server.port = 8989
|
||||||
srs.splitPath=/data/java/srs/stream_server/temp
|
srs.splitPath=/data/java/srs/stream_server/temp
|
||||||
srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html
|
srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html
|
||||||
#srs.splitPath=/Users/sunpeng/workspace/stream/temp
|
#srs.splitPath=/Users/sunpeng/workspace/stream/temp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue