From 67ccc748e71f03db22759e9639f1faad2444fa6c Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Thu, 5 Oct 2023 18:31:59 +0800 Subject: [PATCH] =?UTF-8?q?download=20=E6=B7=BB=E5=8A=A0=20=E5=80=8D?= =?UTF-8?q?=E9=80=9F=E5=8F=82=E6=95=B0=20-filter:v=20"setpts=3D4.0*PTS"=20?= =?UTF-8?q?4=E5=80=8D=E9=80=9F=E6=8E=A8=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docking/gb28181/mocking/config/sip/FfmpegConfig.java | 1 + .../gb28181/mocking/service/ffmpeg/FfmpegSupportService.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/FfmpegConfig.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/FfmpegConfig.java index b8f5435..fe29592 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/FfmpegConfig.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/FfmpegConfig.java @@ -15,6 +15,7 @@ public class FfmpegConfig { @Data public static class Rtp { + private double downloadSpeed = 4.0; private String download = "-i"; private String input = "-re -i"; private String output = "-vcodec h264 -acodec aac -f rtp_mpegts"; diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/ffmpeg/FfmpegSupportService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/ffmpeg/FfmpegSupportService.java index a39203a..763388d 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/ffmpeg/FfmpegSupportService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/ffmpeg/FfmpegSupportService.java @@ -8,6 +8,7 @@ import org.apache.commons.exec.*; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.text.MessageFormat; import java.util.concurrent.TimeUnit; @Slf4j @@ -33,7 +34,8 @@ public class FfmpegSupportService { public Executor pushDownload2Rtp(String input, String output, long time, TimeUnit unit, ExecuteResultHandler resultHandler){ FfmpegConfig.Rtp rtp = ffmpegConfig.getRtp(); FfmpegConfig.Debug debug = ffmpegConfig.getDebug(); - String inputParam = debug.getDownload()? rtp.getDownload() : StringUtils.joinWith(" ", rtp.getDownload(), input); + String downloadSpeed = StringUtils.joinWith(" ","-filter:v", MessageFormat.format("\"setpts={0}*PTS\"",rtp.getDownloadSpeed())); + String inputParam = debug.getDownload()? rtp.getDownload() : StringUtils.joinWith(" ", rtp.getDownload(), input, downloadSpeed); log.info("视频下载参数 {}", inputParam); String outputParam = debug.getOutput()? rtp.getOutput() : StringUtils.joinWith(" ", rtp.getOutput(), output);