Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ public abstract class AbstractFFmpegOutputBuilder<T extends AbstractFFmpegOutput
@Deprecated
public String video_bit_stream_filter;

protected String complexFilter;
/**
* Specifies the number of b-frames ffmpeg is allowed to use.
* 0 will disable b-frames, null will let ffmpeg decide.
*/
protected Integer bFrames;

protected String complexFilter;

public AbstractFFmpegOutputBuilder() {
super();
Expand Down Expand Up @@ -120,6 +126,18 @@ public T setVideoPreset(String preset) {
return (T) this;
}

/**
* Sets the number of b-frames ffmpeg is allowed to use.
* 0 means: Do not use b-frames at all
*
* @param bFrames number of b-frames
* @return this
*/
public T setBFrames(int bFrames) {
this.bFrames = bFrames;
return (T) this;
}

/**
* Sets Video Filter
*
Expand Down Expand Up @@ -365,6 +383,10 @@ protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String>
if (!Strings.isNullOrEmpty(video_bit_stream_filter)) {
args.add("-bsf:v", video_bit_stream_filter);
}

if (bFrames != null) {
args.add("-bf", Integer.toString(bFrames));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ public void testSetComplexFilter() {

assertThat(removeCommon(command), is(ImmutableList.of("-filter_complex", "complex-filter")));
}

@Test
public void testSetBFrames() {
List<String> command = getBuilder()
.setBFrames(2)
.build(0);

assertThat(removeCommon(command), is(ImmutableList.of("-bf", "2")));
}
}