HLSFFmpegBuilder适用于hls协议的构造器 没具体测试
  3OWcH55z3bwR 2023年11月02日 63 0
import com.google.common.collect.ImmutableList;
import net.bramp.ffmpeg.builder.FFmpegBuilder;

import java.util.ArrayList;
import java.util.List;

/***
* 适用于hls协议的构造器,<a href="https://ffmpeg.org/ffmpeg-formats.html#hls-1">hls协议相关参数</a>
* @author dqk
*/

public class HLSFFmpegBuilder extends FFmpegBuilder {

/***
* Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.
*/
private Integer hlsListSize = 5;

/***
* Set the target segment length in seconds. Default value is 2. Segment will be cut on the next key frame after this time has passed.
*/
private Integer hlsTime = 2;

/***
* This is a deprecated option, you can use hls_list_size and hls_flags delete_segments instead it
*
* This option is useful to avoid to fill the disk with many segment files, and limits the maximum number of segment files written to disk to wrap.
*/
@Deprecated
private Integer hlsWrap = 0;

public HLSFFmpegBuilder setHlsListSize(Integer hlsListSize) {
this.hlsListSize = hlsListSize;
return this;
}

public HLSFFmpegBuilder setHlsTime(Integer hlsTime) {
this.hlsTime = hlsTime;
return this;
}

public HLSFFmpegBuilder setHlsWrap(Integer hlsWrap) {
this.hlsWrap = hlsWrap;
return this;
}

public Integer getHlsListSize() {
return hlsListSize;
}

public Integer getHlsTime() {
return hlsTime;
}

public Integer getHlsWrap() {
return hlsWrap;
}

@Override
public List<String> build() {
List<String> args = super.build();
List<String> temp = new ArrayList<>();

setFormat("hls");

if(this.hlsWrap != null){
temp.add("-hls_wrap");
temp.add(hlsWrap.toString());
}

if(this.hlsTime != null){
temp.add("-hls_time");
temp.add(hlsTime.toString());
}

if(this.hlsListSize != null){
temp.add("-hls_list_size");
temp.add(hlsListSize.toString());
}

for(String arg: temp){
args.add(arg);
}
List<String> newargs = ImmutableList.copyOf(args);
return newargs;
}
}
GkFFmpegBuilder.java
import com.google.common.collect.ImmutableList;
import net.bramp.ffmpeg.builder.FFmpegBuilder;

import java.util.ArrayList;
import java.util.List;

/**
* 为了方便拓展api中没有的参数
*/

public class GkFFmpegBuilder extends FFmpegBuilder {

private Long itsoffset;

@Override
public List<String> build() {
// 该数组为不可变数组 (原因未知)
List<String> args = super.build();
List<String> temp = new ArrayList<>();
if(this.itsoffset != null){
temp.add("-itsoffset");
temp.add(this.itsoffset.toString());
}

for(String arg: args){
temp.add(arg);
}
List<String> newargs = ImmutableList.copyOf(temp);
return newargs;
}

public Long getItsoffset() {
return itsoffset;
}

public GkFFmpegBuilder setItsoffset(Long itsoffset) {
this.itsoffset = itsoffset;
return this;
}

}

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  b1UHV4WKBb2S   2023年11月13日   39   0   0 ide抗锯齿
  b1UHV4WKBb2S   2023年11月13日   33   0   0 裁剪ideflutter
  zSWNgACtCQuP   2023年11月13日   29   0   0 ide
3OWcH55z3bwR