Skip to content

Commit 25acdc4

Browse files
authored
Feature/346 add bf option (#351)
* feat: Add support for -bf option Fixes: #346
1 parent bfb63a3 commit 25acdc4

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ public abstract class AbstractFFmpegOutputBuilder<T extends AbstractFFmpegOutput
6767
@Deprecated
6868
public String video_bit_stream_filter;
6969

70-
protected String complexFilter;
70+
/**
71+
* Specifies the number of b-frames ffmpeg is allowed to use.
72+
* 0 will disable b-frames, null will let ffmpeg decide.
73+
*/
74+
protected Integer bFrames;
75+
76+
protected String complexFilter;
7177

7278
public AbstractFFmpegOutputBuilder() {
7379
super();
@@ -120,6 +126,18 @@ public T setVideoPreset(String preset) {
120126
return (T) this;
121127
}
122128

129+
/**
130+
* Sets the number of b-frames ffmpeg is allowed to use.
131+
* 0 means: Do not use b-frames at all
132+
*
133+
* @param bFrames number of b-frames
134+
* @return this
135+
*/
136+
public T setBFrames(int bFrames) {
137+
this.bFrames = bFrames;
138+
return (T) this;
139+
}
140+
123141
/**
124142
* Sets Video Filter
125143
*
@@ -365,6 +383,10 @@ protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String>
365383
if (!Strings.isNullOrEmpty(video_bit_stream_filter)) {
366384
args.add("-bsf:v", video_bit_stream_filter);
367385
}
386+
387+
if (bFrames != null) {
388+
args.add("-bf", Integer.toString(bFrames));
389+
}
368390
}
369391

370392
@Override

src/test/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilderTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,13 @@ public void testSetComplexFilter() {
111111

112112
assertThat(removeCommon(command), is(ImmutableList.of("-filter_complex", "complex-filter")));
113113
}
114+
115+
@Test
116+
public void testSetBFrames() {
117+
List<String> command = getBuilder()
118+
.setBFrames(2)
119+
.build(0);
120+
121+
assertThat(removeCommon(command), is(ImmutableList.of("-bf", "2")));
122+
}
114123
}

0 commit comments

Comments
 (0)