diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/video/VideoService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/video/VideoService.java index 08b6f37..c718d73 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/video/VideoService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/video/VideoService.java @@ -3,7 +3,6 @@ package cn.skcks.docking.gb28181.wvp.service.video; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.IoUtil; import cn.skcks.docking.gb28181.core.sip.utils.SipUtil; import cn.skcks.docking.gb28181.wvp.config.ProxySipConfig; import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig; @@ -32,7 +31,9 @@ import org.bytedeco.javacv.FFmpegFrameRecorder; import org.bytedeco.javacv.FrameGrabber; import org.springframework.stereotype.Service; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.Optional; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -231,9 +232,8 @@ public class VideoService { @SneakyThrows public void ffmpegRecord(ServletResponse response, String url, long time, WvpProxyDevice device,String callId){ ServletOutputStream outputStream = response.getOutputStream(); - PipedOutputStream pipedOutputStream = new PipedOutputStream(); ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); - PumpStreamHandler streamHandler = new PumpStreamHandler(pipedOutputStream, errorStream); + PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream, errorStream); DefaultExecuteResultHandler executeResultHandler = mediaStatus(device,callId); DateTime startTime = DateUtil.date(); Executor executor; @@ -249,13 +249,10 @@ public class VideoService { log.info("结束录制 {}", url); }, time, TimeUnit.SECONDS); executeResultHandler.waitFor(); - - DataInputStream is = new DataInputStream(new PipedInputStream(pipedOutputStream)); - IoUtil.copy(is,outputStream); - schedule.cancel(true); DateTime endTime = DateUtil.date(); log.info("录制进程结束 {}, 录制耗时: {}", url, DateUtil.between(startTime,endTime, DateUnit.SECOND)); + outputStream.close(); } /**