diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index 8f686b44..25e783fb 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -16,6 +16,24 @@ + + + + + + + + + + diff --git a/pom.xml b/pom.xml index b3a462eb..df07dace 100644 --- a/pom.xml +++ b/pom.xml @@ -292,7 +292,7 @@ com.puppycrawl.tools checkstyle - 13.4.2 + 14.3.0 diff --git a/src/main/java/net/bramp/ffmpeg/FFmpeg.java b/src/main/java/net/bramp/ffmpeg/FFmpeg.java index 760317e7..04ccf617 100644 --- a/src/main/java/net/bramp/ffmpeg/FFmpeg.java +++ b/src/main/java/net/bramp/ffmpeg/FFmpeg.java @@ -124,17 +124,22 @@ public FFmpeg(@Nonnull String path, @Nonnull ProcessFunction runFunction) throws * @return true iff this is the official ffmpeg binary. * @throws IOException If a I/O error occurs while executing ffmpeg. */ - public boolean isFFmpeg() throws IOException { + public boolean isFfmpeg() throws IOException { return version().startsWith("ffmpeg"); } + /** Returns whether this is ffmpeg, preserving the original method name. */ + public boolean isFFmpeg() throws IOException { + return isFfmpeg(); + } + /** * Throws an exception if this is an unsupported version of ffmpeg. * * @throws IllegalArgumentException if this is not the official ffmpeg binary. * @throws IOException If a I/O error occurs while executing ffmpeg. */ - private void checkIfFFmpeg() throws IllegalArgumentException, IOException { + private void checkIfFfmpeg() throws IllegalArgumentException, IOException { if (!isFFmpeg()) { throw new IllegalArgumentException( "This binary '" + path + "' is not a supported version of ffmpeg"); @@ -143,7 +148,7 @@ private void checkIfFFmpeg() throws IllegalArgumentException, IOException { /** Returns the list of supported codecs. */ public synchronized @Nonnull List codecs() throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); if (this.codecs == null) { codecs = new ArrayList<>(); @@ -173,7 +178,7 @@ private void checkIfFFmpeg() throws IllegalArgumentException, IOException { /** Returns the list of supported filters. */ public synchronized @Nonnull List filters() throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); if (this.filters == null) { filters = new ArrayList<>(); @@ -213,7 +218,7 @@ private void checkIfFFmpeg() throws IllegalArgumentException, IOException { /** Returns the list of supported formats. */ public synchronized @Nonnull List formats() throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); if (this.formats == null) { formats = new ArrayList<>(); @@ -242,7 +247,7 @@ private void checkIfFFmpeg() throws IllegalArgumentException, IOException { /** Returns the list of supported pixel formats. */ public synchronized List pixelFormats() throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); if (this.pixelFormats == null) { pixelFormats = new ArrayList<>(); @@ -275,7 +280,7 @@ public synchronized List pixelFormats() throws IOException { /** Returns the list of supported channel layouts. */ public synchronized List channelLayouts() throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); if (this.channelLayouts == null) { Process p = runFunc.run(ImmutableList.of(path, "-layouts")); @@ -305,7 +310,7 @@ protected ProgressParser createProgressParser(ProgressListener listener) throws @Override public void run(List args) throws IOException { - checkIfFFmpeg(); + checkIfFfmpeg(); super.run(args); } diff --git a/src/main/java/net/bramp/ffmpeg/FFprobe.java b/src/main/java/net/bramp/ffmpeg/FFprobe.java index e33e1b9e..99839f6b 100644 --- a/src/main/java/net/bramp/ffmpeg/FFprobe.java +++ b/src/main/java/net/bramp/ffmpeg/FFprobe.java @@ -77,7 +77,7 @@ public FFmpegProbeResult probe( // TODO: Add Probe Inputstream /** Probes media using the supplied arguments and returns the result. */ public FFmpegProbeResult probe(List args) throws IOException { - checkIfFFprobe(); + checkIfFfprobe(); Process p = runFunc.run(path(args)); try { @@ -108,17 +108,22 @@ public FFmpegProbeResult probe(List args) throws IOException { * @return true iff this is the official ffprobe binary. * @throws IOException If a I/O error occurs while executing ffprobe. */ - public boolean isFFprobe() throws IOException { + public boolean isFfprobe() throws IOException { return version().startsWith("ffprobe"); } + /** Returns whether this is ffprobe, preserving the original method name. */ + public boolean isFFprobe() throws IOException { + return isFfprobe(); + } + /** * Throws an exception if this is an unsupported version of ffprobe. * * @throws IllegalArgumentException if this is not the official ffprobe binary. * @throws IOException If a I/O error occurs while executing ffprobe. */ - private void checkIfFFprobe() throws IllegalArgumentException, IOException { + private void checkIfFfprobe() throws IllegalArgumentException, IOException { if (!isFFprobe()) { throw new IllegalArgumentException( "This binary '" + path + "' is not a supported version of ffprobe"); @@ -127,7 +132,7 @@ private void checkIfFFprobe() throws IllegalArgumentException, IOException { @Override public void run(List args) throws IOException { - checkIfFFprobe(); + checkIfFfprobe(); super.run(args); } diff --git a/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java index c5dac478..523c67d4 100644 --- a/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java +++ b/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java @@ -174,11 +174,21 @@ public T setVideoPreset(String preset) { * @param bFrames number of b-frames * @return this */ - public T setBFrames(int bFrames) { + public T setBframes(int bFrames) { this.bFrames = bFrames; return (T) this; } + /** + * Sets the number of b-frames using the original method name. + * + * @param bFrames number of b-frames + * @return this + */ + public T setBFrames(int bFrames) { + return setBframes(bFrames); + } + /** * Sets Video Filter. * diff --git a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java index 69694f0a..7bac6ec9 100644 --- a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java +++ b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java @@ -327,12 +327,22 @@ public FFmpegBuilder setVideoFilter(String filter) { * @param quality the quality between 0 and 9. Where 0 is best. * @return FFmpegBuilder */ - public FFmpegBuilder setVBR(Integer quality) { + public FFmpegBuilder setVbr(Integer quality) { Preconditions.checkArgument(quality > 0 && quality < 9, "vbr must be between 0 and 9"); this.qscale = quality; return this; } + /** + * Sets the VBR quality using the original method name. + * + * @param quality the quality between 0 and 9. Where 0 is best. + * @return this + */ + public FFmpegBuilder setVBR(Integer quality) { + return setVbr(quality); + } + /** * Add additional ouput arguments (for flags which aren't currently supported). * diff --git a/src/main/java/net/bramp/ffmpeg/nut/NutDataInputStream.java b/src/main/java/net/bramp/ffmpeg/nut/NutDataInputStream.java index 72d9d3ae..480856e3 100644 --- a/src/main/java/net/bramp/ffmpeg/nut/NutDataInputStream.java +++ b/src/main/java/net/bramp/ffmpeg/nut/NutDataInputStream.java @@ -29,17 +29,27 @@ public NutDataInputStream(InputStream in) { } /** Resets the CRC32 checksum for a new calculation range. */ - public void resetCRC() { + public void resetCrc() { startCrcRange = count.getCount(); crc.resetCrc(); } + /** Resets the CRC32 checksum using the original method name. */ + public void resetCRC() { + resetCrc(); + } + /** Returns the current CRC32 checksum value. */ - public long getCRC() { + public long getCrc() { endCrcRange = count.getCount(); return crc.getValue(); } + /** Returns the CRC32 checksum using the original method name. */ + public long getCRC() { + return getCrc(); + } + /** Reads a variable-length encoded integer up to 32 bits. */ public int readVarInt() throws IOException { boolean more; diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java index 0dcf8d93..b18bd155 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java @@ -110,10 +110,15 @@ public int getHeight() { return height; } - public int getHasBFrames() { + public int getHasBframes() { return has_b_frames; } + /** Returns the number of B-frames, preserving the original method name. */ + public int getHasBFrames() { + return getHasBframes(); + } + public String getSampleAspectRatio() { return sample_aspect_ratio; } @@ -150,10 +155,15 @@ public String getId() { return id; } - public Fraction getRFrameRate() { + public Fraction getRframeRate() { return r_frame_rate; } + /** Returns the real frame rate, preserving the original method name. */ + public Fraction getRFrameRate() { + return getRframeRate(); + } + public Fraction getAvgFrameRate() { return avg_frame_rate; } diff --git a/src/test/java/net/bramp/ffmpeg/FFmpegTest.java b/src/test/java/net/bramp/ffmpeg/FFmpegTest.java index ffe97d61..ae65b315 100644 --- a/src/test/java/net/bramp/ffmpeg/FFmpegTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFmpegTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.hasItem; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; import static org.mockito.hamcrest.MockitoHamcrest.argThat; @@ -60,6 +61,8 @@ public static List argThatHasItem(T s) { public void testVersion() throws Exception { assertEquals("ffmpeg version 0.10.9-7:0.10.9-1~raring1", ffmpeg.version()); assertEquals("ffmpeg version 0.10.9-7:0.10.9-1~raring1", ffmpeg.version()); + assertTrue(ffmpeg.isFfmpeg()); + assertTrue(ffmpeg.isFFmpeg()); verify(runFunc, times(1)).run(argThatHasItem("-version")); } diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index 68fb5792..c8684ac6 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -88,6 +88,8 @@ public void testVersion() throws Exception { "ffprobe version 3.0.2 Copyright (c) 2007-2016 the FFmpeg developers", ffprobe.version()); assertEquals( "ffprobe version 3.0.2 Copyright (c) 2007-2016 the FFmpeg developers", ffprobe.version()); + assertTrue(ffprobe.isFfprobe()); + assertTrue(ffprobe.isFFprobe()); verify(runFunc, times(1)).run(argThatHasItem("-version")); } @@ -629,6 +631,7 @@ public void testFullVideoStreamDeserialization() throws IOException { assertEquals(1280, stream.getWidth()); assertEquals(720, stream.getHeight()); assertEquals(0, stream.getHasBFrames()); + assertEquals(stream.getHasBFrames(), stream.getHasBframes()); assertEquals("1:1", stream.getSampleAspectRatio()); assertEquals("16:9", stream.getDisplayAspectRatio()); assertEquals("yuv420p", stream.getPixFmt()); @@ -639,6 +642,7 @@ public void testFullVideoStreamDeserialization() throws IOException { assertEquals("4", stream.getNalLengthSize()); assertEquals("0x1", stream.getId()); assertEquals(Fraction.getFraction(25, 1), stream.getRFrameRate()); + assertEquals(stream.getRFrameRate(), stream.getRframeRate()); assertEquals(Fraction.getFraction(25, 1), stream.getAvgFrameRate()); assertEquals(Fraction.getFraction(1, 12800), stream.getTimeBase()); assertEquals(0, stream.getStartPts()); diff --git a/src/test/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilderTest.java b/src/test/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilderTest.java index 9b6b2990..7fe98580 100644 --- a/src/test/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilderTest.java +++ b/src/test/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilderTest.java @@ -92,7 +92,9 @@ public void testSetComplexFilter() { @Test public void testSetBFrames() { List command = getBuilder().setBFrames(2).build(0); + List styledCommand = getBuilder().setBframes(2).build(0); assertThat(removeCommon(command), is(ImmutableList.of("-bf", "2"))); + assertThat(removeCommon(styledCommand), is(ImmutableList.of("-bf", "2"))); } } diff --git a/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java b/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java index f80fe6d9..9bb14fd5 100644 --- a/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java +++ b/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java @@ -455,10 +455,14 @@ public void testExtraArgs() { @Test public void testVbr() { List args = - new FFmpegBuilder().setInput("input").done().setVBR(2).addOutput("output").done().build(); + new FFmpegBuilder().setInput("input").done().setVbr(2).addOutput("output").done().build(); assertEquals( args, ImmutableList.of("-y", "-v", "error", "-i", "input", "-qscale:a", "2", "output")); + + List legacyArgs = + new FFmpegBuilder().setInput("input").done().setVBR(2).addOutput("output").done().build(); + assertEquals(args, legacyArgs); } @Test(expected = IllegalArgumentException.class)