修正 ffmpegRecord 时间范围
This commit is contained in:
parent
b4be3825bc
commit
dda2d2fc07
@ -27,6 +27,7 @@ import cn.skcks.docking.gb28181.service.ssrc.SsrcService;
|
||||
import cn.skcks.docking.gb28181.wvp.config.MediaRtmpConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.ProxySipConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.report.ReportReq;
|
||||
import cn.skcks.docking.gb28181.wvp.executor.DefaultVideoExecutor;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
|
||||
@ -231,7 +232,7 @@ public class Gb28181DownloadService {
|
||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||
} else if (wvpProxyConfig.getUseFfmpeg()) {
|
||||
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), new ReportReq.TimeRange(startTime, endTime), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
DateTime end = DateUtil.date();
|
||||
asyncContext.complete();
|
||||
log.info("下载总耗时: {}, deviceCode {}, startTime {}, endTime {}", DateUtil.between(start, end, DateUnit.SECOND), deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
@ -376,7 +377,7 @@ public class Gb28181DownloadService {
|
||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||
} else if(wvpProxyConfig.getUseFfmpeg()){
|
||||
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), new ReportReq.TimeRange(startTime, endTime), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
DateTime end = DateUtil.date();
|
||||
asyncContext.complete();
|
||||
log.info("下载总耗时: {}, deviceCode {}, startTime {}, endTime {}", DateUtil.between(start, end, DateUnit.SECOND), deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
|
@ -8,6 +8,7 @@ import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
|
||||
import cn.skcks.docking.gb28181.wvp.config.FfmpegConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.ProxySipConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.report.ReportReq;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
|
||||
import cn.skcks.docking.gb28181.wvp.service.docking.DockingService;
|
||||
@ -233,7 +234,7 @@ public class VideoService {
|
||||
* @param time 录制时长 (单位: 秒)
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void ffmpegRecord(HttpServletRequest request, ServletResponse response, String url, long time, WvpProxyDevice device,String callId){
|
||||
public void ffmpegRecord(HttpServletRequest request, ServletResponse response, String url, ReportReq.TimeRange timeRange, long time, WvpProxyDevice device, String callId){
|
||||
String tmpDir = ffmpegConfig.getTmpDir();
|
||||
String fileName = callId + ".mp4";
|
||||
File file = new File(tmpDir, fileName);
|
||||
@ -276,9 +277,9 @@ public class VideoService {
|
||||
log.info("临时文件 {}(大小 {})", file.getAbsolutePath(), file.length());
|
||||
IoUtil.copy(new FileInputStream(file), servletOutputStream);
|
||||
response.flushBuffer();
|
||||
reportService.report(request, device, startTime, endTime, file.length());
|
||||
reportService.report(request, device, timeRange.getStartTime(), timeRange.getEndTime(), file.length());
|
||||
} catch (Exception e){
|
||||
reportService.report(request, device, startTime, endTime, -1);
|
||||
reportService.report(request, device, timeRange.getStartTime(), timeRange.getEndTime(), -1);
|
||||
log.error("写入 http 响应异常: {}", e.getMessage());
|
||||
} finally {
|
||||
System.gc();
|
||||
|
Loading…
Reference in New Issue
Block a user