download 添加 倍速参数 -filter:v "setpts=4.0*PTS" 4倍速推流

This commit is contained in:
shikong 2023-10-05 18:31:59 +08:00
parent 260ac344a9
commit 67ccc748e7
2 changed files with 4 additions and 1 deletions

View File

@ -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";

View File

@ -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);