|
@@ -75,19 +75,20 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
|
|
|
String videoPort = one.getVideoPort().toString();
|
|
|
String command = "ffmpeg -i rtsp://"+accountNumber+":"+videoPassword+"@"+videoIp+":"+videoPort+" -vcodec copy -acodec aac -ar 44100 -c:v libx264 -strict -2 -ac 1 -f flv -r 30 -s 1920x1080 -q 10 -f flv rtmp://"+rtmpIp+":1935/hls/"+deviceUuid;
|
|
|
System.out.println(command);
|
|
|
+ Process process = null;
|
|
|
try {
|
|
|
log.info("【begin】实时拉取摄像头数据流 "+command);
|
|
|
// 创建 ProcessBuilder 实例
|
|
|
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
|
|
|
// 启动进程
|
|
|
- Process process = processBuilder.start();
|
|
|
+ process = processBuilder.start();
|
|
|
|
|
|
// 获取进程的输入流
|
|
|
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
|
- String line;
|
|
|
- while ((line = reader.readLine()) != null) {
|
|
|
- System.out.println(line);
|
|
|
- }
|
|
|
+// BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
|
+// String line;
|
|
|
+// while ((line = reader.readLine()) != null) {
|
|
|
+// System.out.println(line);
|
|
|
+// }
|
|
|
|
|
|
// 等待进程执行完成并获取退出码
|
|
|
int exitCode = process.waitFor();
|
|
@@ -104,6 +105,10 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
|
|
|
} catch (IOException | InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
+ } finally {
|
|
|
+ if (process != null) {
|
|
|
+ process.destroy();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|