Skip to content

Commit d37cded

Browse files
committed
test: Add precondition checks for two pass builder
1 parent 9d82ff2 commit d37cded

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package net.bramp.ffmpeg.builder;
2+
3+
import com.google.common.collect.ImmutableList;
4+
import org.junit.Test;
5+
6+
import java.util.List;
7+
8+
import static net.bramp.ffmpeg.builder.AbstractFFmpegStreamBuilder.DEVNULL;
9+
import static org.hamcrest.core.Is.is;
10+
import static org.hamcrest.MatcherAssert.assertThat;
11+
12+
public class FFmpegBuilderTwoPassTest {
13+
14+
@Test
15+
public void firstPass() {
16+
List<String> command = new FFmpegBuilder()
17+
.addInput("input.mp4")
18+
.done()
19+
.addOutput("output.mp4")
20+
.setVideoBitRate(1_000_000)
21+
.setFormat("mp4")
22+
.done()
23+
.setPass(1)
24+
.build();
25+
26+
assertThat(command, is(ImmutableList.of("-y", "-v", "error", "-an", "-i", "input.mp4", "-pass", "1", "-f", "mp4", "-b:v", "1000000", "-an", DEVNULL)));
27+
}
28+
29+
@Test
30+
public void secondPass() {
31+
List<String> command = new FFmpegBuilder()
32+
.addInput("input.mp4")
33+
.done()
34+
.addOutput("output.mp4")
35+
.setVideoBitRate(1_000_000)
36+
.setFormat("mp4")
37+
.done()
38+
.setPass(2)
39+
.build();
40+
41+
assertThat(command, is(ImmutableList.of("-y", "-v", "error", "-i", "input.mp4", "-pass", "2", "-f", "mp4", "-b:v", "1000000", "output.mp4")));
42+
}
43+
44+
@Test(expected = IllegalArgumentException.class)
45+
public void firstPassNoBitrate() {
46+
List<String> ignored = new FFmpegBuilder()
47+
.addInput("input.mp4")
48+
.done()
49+
.addOutput("output.mp4")
50+
.setFormat("mp4")
51+
.done()
52+
.setPass(1)
53+
.build();
54+
}
55+
56+
@Test(expected = IllegalArgumentException.class)
57+
public void secondPassNoBitrate() {
58+
List<String> ignored = new FFmpegBuilder()
59+
.addInput("input.mp4")
60+
.done()
61+
.addOutput("output.mp4")
62+
.setFormat("mp4")
63+
.done()
64+
.setPass(2)
65+
.build();
66+
}
67+
68+
@Test(expected = IllegalArgumentException.class)
69+
public void firstPassNoFormat() {
70+
List<String> ignored = new FFmpegBuilder()
71+
.addInput("input.mp4")
72+
.done()
73+
.addOutput("output.mp4")
74+
.setVideoBitRate(1_000_000)
75+
.done()
76+
.setPass(1)
77+
.build();
78+
}
79+
80+
@Test(expected = IllegalArgumentException.class)
81+
public void secondPassNoFormat() {
82+
List<String> ignored = new FFmpegBuilder()
83+
.addInput("input.mp4")
84+
.done()
85+
.addOutput("output.mp4")
86+
.setVideoBitRate(1_000_000)
87+
.done()
88+
.setPass(2)
89+
.build();
90+
}
91+
}

0 commit comments

Comments
 (0)