Skip to content

Feature/346 add bf option #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2024
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")));
}
}
Loading