diff --git a/README.md b/README.md index 18faa42f..08402a2f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -FFmpeg Java -=========== +# FFmpeg CLI Wrapper for Java -by Andrew Brampton ([bramp.net](https://bramp.net)) (c) 2013-2014,2016 +by Andrew Brampton ([bramp.net](https://bramp.net)) (c) 2013-2024 [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bramp) -A fluent interface to running FFmpeg from Java. +A fluent interface for running FFmpeg from Java. ![Java](https://img.shields.io/badge/Java-8+-brightgreen.svg) [![Build Status](https://github.com/bramp/ffmpeg-cli-wrapper/actions/workflows/maven.yml/badge.svg)](https://github.com/bramp/ffmpeg-cli-wrapper/actions/workflows/maven.yml) @@ -15,8 +14,7 @@ A fluent interface to running FFmpeg from Java. [GitHub](https://github.com/bramp/ffmpeg-cli-wrapper) | [API docs](https://bramp.github.io/ffmpeg-cli-wrapper/) -Install -------- +## Install We currently support Java 8 and above. Use Maven to install the dependency. @@ -28,12 +26,12 @@ We currently support Java 8 and above. Use Maven to install the dependency. ``` -Usage ------ +## Usage ### Video Encoding Code: + ```java FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg"); FFprobe ffprobe = new FFprobe("/path/to/ffprobe"); @@ -73,64 +71,67 @@ executor.createTwoPassJob(builder).run(); ### Get Media Information Code: + ```java FFprobe ffprobe = new FFprobe("/path/to/ffprobe"); FFmpegProbeResult probeResult = ffprobe.probe("input.mp4"); FFmpegFormat format = probeResult.getFormat(); System.out.format("%nFile: '%s' ; Format: '%s' ; Duration: %.3fs", - format.filename, - format.format_long_name, - format.duration + format.filename, + format.format_long_name, + format.duration ); FFmpegStream stream = probeResult.getStreams().get(0); System.out.format("%nCodec: '%s' ; Width: %dpx ; Height: %dpx", - stream.codec_long_name, - stream.width, - stream.height + stream.codec_long_name, + stream.width, + stream.height ); ``` ### Get progress while encoding + ```java FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe); FFmpegProbeResult in = ffprobe.probe("input.flv"); FFmpegBuilder builder = new FFmpegBuilder() - .setInput(in) // Or filename - .addOutput("output.mp4") - .done(); + .setInput(in) // Or filename + .addOutput("output.mp4") + .done(); FFmpegJob job = executor.createJob(builder, new ProgressListener() { - // Using the FFmpegProbeResult determine the duration of the input - final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1); - - @Override - public void progress(Progress progress) { - double percentage = progress.out_time_ns / duration_ns; - - // Print out interesting information about the progress - System.out.println(String.format( - "[%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx", - percentage * 100, - progress.status, - progress.frame, - FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS), - progress.fps.doubleValue(), - progress.speed - )); - } + // Using the FFmpegProbeResult determine the duration of the input + final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1); + + @Override + public void progress(Progress progress) { + double percentage = progress.out_time_ns / duration_ns; + + // Print out interesting information about the progress + System.out.println(String.format( + "[%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx", + percentage * 100, + progress.status, + progress.frame, + FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS), + progress.fps.doubleValue(), + progress.speed + )); + } }); job.run(); ``` -Building & Releasing --------------- +## Building & Releasing + If you wish to make changes, then building and releasing is simple: + ```bash # To build mvn @@ -148,8 +149,7 @@ git checkout ffmpeg-0.x mvn clean javadoc:aggregate scm-publish:publish-scm ``` -Bumpings Deps ------ +## Bumpings Deps ```bash # Update Maven Plugins @@ -159,15 +159,13 @@ mvn versions:display-plugin-updates mvn versions:display-dependency-updates ``` -Install FFmpeg on Ubuntu ------------------ +## Install FFmpeg on Ubuntu We only the support the original FFmpeg, not the libav version. Before Ubuntu 12.04, and in 15.04 and later the original FFmpeg is shipped. If you have to run on a version with libav, you can install FFmpeg from a PPA, or using the static build. More information [here](http://askubuntu.com/q/373322/34845) -Get involved! -------------- +## Get involved We welcome contributions. Please check the [issue tracker](https://github.com/bramp/ffmpeg-cli-wrapper/issues). If you see something you wish to work on, please either comment on the issue, or just send a pull @@ -175,10 +173,10 @@ request. Want to work on something else, then just open a issue, and we can disc documentation improvements, code cleanup, or new features. Please be mindful that all work is done on a volunteer basis, thus we can be slow to reply. -Licence (Simplified BSD License) --------------------------------- -``` -Copyright (c) 2016-2022, Andrew Brampton +## Licence (Simplified BSD License) + +```plaintext +Copyright (c) 2013-2024, Andrew Brampton All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/pom.xml b/pom.xml index 59d91669..211c649c 100644 --- a/pom.xml +++ b/pom.xml @@ -54,32 +54,32 @@ org.slf4j slf4j-api - 2.0.9 + 2.0.12 com.github.spotbugs spotbugs-annotations - 4.8.0 + 4.8.3 com.google.errorprone error_prone_annotations - 2.23.0 + 2.25.0 com.google.guava guava - 32.1.3-jre + 33.0.0-jre commons-io commons-io - 2.15.0 + 2.15.1 org.apache.commons commons-lang3 - 3.13.0 + 3.14.0 com.google.code.gson @@ -96,7 +96,7 @@ ch.qos.logback logback-classic - 1.4.12 + 1.5.3 @@ -107,7 +107,7 @@ org.mockito mockito-core - 5.6.0 + 5.11.0 org.hamcrest @@ -223,7 +223,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.3.1 + 3.3.2 org.apache.maven.plugins @@ -243,7 +243,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.1 + 3.2.5 org.codehaus.mojo @@ -258,7 +258,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 net.revelc.code @@ -278,7 +278,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 org.apache.maven.plugins @@ -293,7 +293,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins @@ -308,7 +308,7 @@ com.spotify.fmt fmt-maven-plugin - 2.21.1 + 2.23 org.apache.maven.plugins @@ -324,8 +324,6 @@ ${base.java.version} ${base.java.version} - javac-with-errorprone - true true true true @@ -336,20 +334,6 @@ -Xlint:all - - - org.codehaus.plexus - plexus-compiler-javac-errorprone - 2.11.1 - - - - com.google.errorprone - error_prone_core - 2.12.1 - - org.apache.maven.plugins @@ -480,7 +464,7 @@ org.codehaus.mojo extra-enforcer-rules - 1.5.1 + 1.8.0 @@ -541,13 +525,13 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.4.5 + 3.5.0 org.codehaus.mojo versions-maven-plugin - 2.16.1 + 2.16.2 @@ -592,7 +576,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.21.0 + 3.21.2 true @@ -665,7 +649,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.3.1 + 3.3.2 true @@ -683,7 +667,7 @@ org.apache.maven.plugins maven-surefire-report-plugin - 3.2.1 + 3.2.5 ${project.reporting.outputDirectory}/testresults @@ -734,8 +718,8 @@ - + Java 9+ @@ -745,9 +729,43 @@ ${base.java.version} + + + + Java 11+ + + [11,) + + + + org.apache.maven.plugins + maven-compiler-plugin + + true + + + -XDcompilePolicy=simple + -Xplugin:ErrorProne + + + + com.google.errorprone + error_prone_core + 2.25.0 + + + + + + com.spotify.fmt fmt-maven-plugin @@ -762,5 +780,41 @@ + + + Java 16+ + + [16,) + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + + + + + + + diff --git a/src/main/java/net/bramp/ffmpeg/FFmpegUtils.java b/src/main/java/net/bramp/ffmpeg/FFmpegUtils.java index fb42e733..c1f4c26d 100644 --- a/src/main/java/net/bramp/ffmpeg/FFmpegUtils.java +++ b/src/main/java/net/bramp/ffmpeg/FFmpegUtils.java @@ -5,6 +5,7 @@ import static net.bramp.ffmpeg.Preconditions.checkNotEmpty; import com.google.common.base.CharMatcher; +import com.google.errorprone.annotations.InlineMe; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.util.concurrent.TimeUnit; @@ -36,6 +37,10 @@ public final class FFmpegUtils { * @deprecated please use #toTimecode() instead. */ @Deprecated + @InlineMe( + replacement = "FFmpegUtils.toTimecode(milliseconds, MILLISECONDS)", + imports = "net.bramp.ffmpeg.FFmpegUtils", + staticImports = "java.util.concurrent.TimeUnit.MILLISECONDS") public static String millisecondsToString(long milliseconds) { return toTimecode(milliseconds, MILLISECONDS); } diff --git a/src/main/java/net/bramp/ffmpeg/Preconditions.java b/src/main/java/net/bramp/ffmpeg/Preconditions.java index b7910f99..04e20b19 100644 --- a/src/main/java/net/bramp/ffmpeg/Preconditions.java +++ b/src/main/java/net/bramp/ffmpeg/Preconditions.java @@ -3,6 +3,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -41,7 +42,7 @@ public static String checkNotEmpty(String arg, @Nullable Object errorMessage) { */ public static URI checkValidStream(URI uri) throws IllegalArgumentException { String scheme = checkNotNull(uri).getScheme(); - scheme = checkNotNull(scheme, "URI is missing a scheme").toLowerCase(); + scheme = Ascii.toLowerCase(checkNotNull(scheme, "URI is missing a scheme")); if (rtps.contains(scheme)) { return uri; diff --git a/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java index e7fbb3d3..ea7721a5 100644 --- a/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java +++ b/src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java @@ -597,7 +597,7 @@ protected List build(FFmpegBuilder parent, int pass) { } else if (uri != null) { args.add(uri.toString()); } else { - assert (false); + assert false; } return args.build(); diff --git a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java index d3bf6bea..3cf4913a 100644 --- a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java +++ b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java @@ -4,6 +4,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static net.bramp.ffmpeg.Preconditions.checkNotEmpty; +import com.google.common.base.Ascii; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -32,10 +33,10 @@ public enum Strict { UNOFFICIAL, // allow unofficial extensions EXPERIMENTAL; - // ffmpeg command line requires these options in lower case @Override public String toString() { - return name().toLowerCase(); + // ffmpeg command line requires these options in lower case + return Ascii.toLowerCase(name()); } } @@ -52,7 +53,8 @@ public enum Verbosity { @Override public String toString() { - return name().toLowerCase(); + // ffmpeg command line requires these options in lower case + return Ascii.toLowerCase(name()); } } @@ -179,8 +181,8 @@ public FFmpegBuilder addProgress(URI uri) { /** * Sets the complex filter flag. * - * @param filter - * @return + * @param filter the complex filter string + * @return this */ public FFmpegBuilder setComplexFilter(String filter) { this.complexFilter = checkNotEmpty(filter, "filter must not be empty"); @@ -190,8 +192,8 @@ public FFmpegBuilder setComplexFilter(String filter) { /** * Sets the audio filter flag. * - * @param filter - * @return + * @param filter the audio filter string + * @return this */ public FFmpegBuilder setAudioFilter(String filter) { this.audioFilter = checkNotEmpty(filter, "filter must not be empty"); @@ -201,8 +203,8 @@ public FFmpegBuilder setAudioFilter(String filter) { /** * Sets the video filter flag. * - * @param filter - * @return + * @param filter the video filter string + * @return this */ public FFmpegBuilder setVideoFilter(String filter) { this.videoFilter = checkNotEmpty(filter, "filter must not be empty"); @@ -211,6 +213,7 @@ public FFmpegBuilder setVideoFilter(String filter) { /** * Sets vbr quality when decoding mp3 output. + * * @param quality the quality between 0 and 9. Where 0 is best. * @return FFmpegBuilder */ diff --git a/src/main/java/net/bramp/ffmpeg/builder/FFmpegOutputBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/FFmpegOutputBuilder.java index 2765f796..939b05c9 100644 --- a/src/main/java/net/bramp/ffmpeg/builder/FFmpegOutputBuilder.java +++ b/src/main/java/net/bramp/ffmpeg/builder/FFmpegOutputBuilder.java @@ -6,6 +6,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.InlineMe; + import java.net.URI; import java.util.List; import java.util.regex.Pattern; @@ -113,7 +115,8 @@ public FFmpegOutputBuilder setVideoFilter(String filter) { * @deprecated use {@link #setAudioSampleFormat} instead. */ @Deprecated - public FFmpegOutputBuilder setAudioBitDepth(String bit_depth) { + @InlineMe(replacement = "this.setAudioSampleFormat(bit_depth)") + final public FFmpegOutputBuilder setAudioBitDepth(String bit_depth) { return setAudioSampleFormat(bit_depth); } diff --git a/src/main/java/net/bramp/ffmpeg/gson/NamedBitsetAdapter.java b/src/main/java/net/bramp/ffmpeg/gson/NamedBitsetAdapter.java index 2435b225..7af7a44a 100644 --- a/src/main/java/net/bramp/ffmpeg/gson/NamedBitsetAdapter.java +++ b/src/main/java/net/bramp/ffmpeg/gson/NamedBitsetAdapter.java @@ -60,7 +60,7 @@ protected Optional readBoolean(JsonReader reader) throws IOException { protected void setField(T target, String name, boolean value) throws IllegalAccessException { try { Field f = clazz.getField(name); - if ((boolean.class.equals(f.getType()))) { + if (boolean.class.equals(f.getType())) { f.setBoolean(target, value); } else if (int.class.equals(f.getType())) { f.setInt(target, value ? 1 : 0); diff --git a/src/main/java/net/bramp/ffmpeg/info/Codec.java b/src/main/java/net/bramp/ffmpeg/info/Codec.java index 2b168eef..c94a0bc2 100644 --- a/src/main/java/net/bramp/ffmpeg/info/Codec.java +++ b/src/main/java/net/bramp/ffmpeg/info/Codec.java @@ -45,7 +45,7 @@ public Codec(String name, String longName, String flags) { this.longName = Preconditions.checkNotNull(longName).trim(); Preconditions.checkNotNull(flags); - Preconditions.checkArgument(flags.length() == 6, "Format flags is invalid '{}'", flags); + Preconditions.checkArgument(flags.length() == 6, "Format flags is invalid '%s'", flags); this.canDecode = flags.charAt(0) == 'D'; this.canEncode = flags.charAt(1) == 'E'; diff --git a/src/main/java/net/bramp/ffmpeg/info/FilterPattern.java b/src/main/java/net/bramp/ffmpeg/info/FilterPattern.java index 049e04e9..ee50288f 100644 --- a/src/main/java/net/bramp/ffmpeg/info/FilterPattern.java +++ b/src/main/java/net/bramp/ffmpeg/info/FilterPattern.java @@ -21,7 +21,9 @@ public FilterPattern(String pattern) { this.variableStreams = pattern.contains("N"); List streams = new ArrayList<>(); - for (char c : pattern.toCharArray()) { + for (int i = 0; i < pattern.length(); i++) { + final char c = pattern.charAt(i); + if (c == '|' || c == 'N') { // These symbols are handled separately continue; diff --git a/src/main/java/net/bramp/ffmpeg/info/Format.java b/src/main/java/net/bramp/ffmpeg/info/Format.java index 31460b20..64bbd82a 100644 --- a/src/main/java/net/bramp/ffmpeg/info/Format.java +++ b/src/main/java/net/bramp/ffmpeg/info/Format.java @@ -32,7 +32,7 @@ public Format(String name, String longName, String flags) { this.longName = Preconditions.checkNotNull(longName).trim(); Preconditions.checkNotNull(flags); - Preconditions.checkArgument(flags.length() == 2, "Format flags is invalid '{}'", flags); + Preconditions.checkArgument(flags.length() == 2, "Format flags is invalid '%s'", flags); canDemux = flags.charAt(0) == 'D'; canMux = flags.charAt(1) == 'E'; } diff --git a/src/main/java/net/bramp/ffmpeg/info/InfoParser.java b/src/main/java/net/bramp/ffmpeg/info/InfoParser.java index 6898ebcc..8a40ced7 100644 --- a/src/main/java/net/bramp/ffmpeg/info/InfoParser.java +++ b/src/main/java/net/bramp/ffmpeg/info/InfoParser.java @@ -4,6 +4,8 @@ import java.io.IOException; import java.util.*; +import com.google.common.base.Splitter; + public final class InfoParser { private InfoParser() { throw new AssertionError("No instances for you!"); @@ -35,7 +37,7 @@ public static List parseLayouts(BufferedReader r) throws IOExcept } else if (parsingChannelLayouts) { String[] s = line.split(" ", 2); List decomposition = new ArrayList<>(); - for (String channelName : s[1].trim().split("\\+")) { + for (String channelName : Splitter.on('+').split(s[1].trim())) { decomposition.add(individualChannelLookup.get(channelName)); } diff --git a/src/main/java/net/bramp/ffmpeg/io/ProcessUtils.java b/src/main/java/net/bramp/ffmpeg/io/ProcessUtils.java index 2869cb57..f51f8224 100644 --- a/src/main/java/net/bramp/ffmpeg/io/ProcessUtils.java +++ b/src/main/java/net/bramp/ffmpeg/io/ProcessUtils.java @@ -4,6 +4,8 @@ import java.util.concurrent.TimeoutException; /** + * A collection of utility methods for dealing with processes. + * * @author bramp */ public final class ProcessUtils { diff --git a/src/main/java/net/bramp/ffmpeg/job/FFmpegJob.java b/src/main/java/net/bramp/ffmpeg/job/FFmpegJob.java index 14404233..47298193 100644 --- a/src/main/java/net/bramp/ffmpeg/job/FFmpegJob.java +++ b/src/main/java/net/bramp/ffmpeg/job/FFmpegJob.java @@ -7,6 +7,8 @@ import net.bramp.ffmpeg.progress.ProgressListener; /** + * A FFmpegJob is a single job that can be run by FFmpeg. It can be a single pass, or a two pass job. + * * @author bramp */ public abstract class FFmpegJob implements Runnable { diff --git a/src/main/java/net/bramp/ffmpeg/job/SinglePassFFmpegJob.java b/src/main/java/net/bramp/ffmpeg/job/SinglePassFFmpegJob.java index 13662d2c..2094fc9a 100644 --- a/src/main/java/net/bramp/ffmpeg/job/SinglePassFFmpegJob.java +++ b/src/main/java/net/bramp/ffmpeg/job/SinglePassFFmpegJob.java @@ -25,6 +25,7 @@ public SinglePassFFmpegJob( // Build the args now (but throw away the results). This allows the illegal arguments to be // caught early, but also allows the ffmpeg command to actually alter the arguments when // running. + @SuppressWarnings("unused") List unused = this.builder.build(); } diff --git a/src/main/java/net/bramp/ffmpeg/job/TwoPassFFmpegJob.java b/src/main/java/net/bramp/ffmpeg/job/TwoPassFFmpegJob.java index 8a03ad54..9b4c930e 100644 --- a/src/main/java/net/bramp/ffmpeg/job/TwoPassFFmpegJob.java +++ b/src/main/java/net/bramp/ffmpeg/job/TwoPassFFmpegJob.java @@ -35,6 +35,7 @@ public TwoPassFFmpegJob( // Build the args now (but throw away the results). This allows the illegal arguments to be // caught early, but also allows the ffmpeg command to actually alter the arguments when // running. + @SuppressWarnings("unused") List unused = this.builder.setPass(1).build(); } diff --git a/src/main/java/net/bramp/ffmpeg/nut/Frame.java b/src/main/java/net/bramp/ffmpeg/nut/Frame.java index e50f1cb9..961b7f9f 100644 --- a/src/main/java/net/bramp/ffmpeg/nut/Frame.java +++ b/src/main/java/net/bramp/ffmpeg/nut/Frame.java @@ -1,6 +1,7 @@ package net.bramp.ffmpeg.nut; import com.google.common.base.MoreObjects; + import java.io.EOFException; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -145,6 +146,7 @@ public void read(NutReader nut, NutDataInputStream in, int code) throws IOExcept } if ((flags & FLAG_CHECKSUM) == FLAG_CHECKSUM) { + @SuppressWarnings("unused") long checksum = in.readInt(); // TODO Test checksum } diff --git a/src/main/java/net/bramp/ffmpeg/nut/MainHeaderPacket.java b/src/main/java/net/bramp/ffmpeg/nut/MainHeaderPacket.java index 16c6c47a..60fca458 100644 --- a/src/main/java/net/bramp/ffmpeg/nut/MainHeaderPacket.java +++ b/src/main/java/net/bramp/ffmpeg/nut/MainHeaderPacket.java @@ -94,7 +94,7 @@ protected void readBody(NutDataInputStream in) throws IOException { if (fields > 5) { count = in.readVarLong(); } else { - count = mul - size; + count = (long) mul - size; } if (fields > 6) { match = in.readSignedVarInt(); diff --git a/src/main/java/net/bramp/ffmpeg/options/EncodingOptions.java b/src/main/java/net/bramp/ffmpeg/options/EncodingOptions.java index bb2528ad..b93f4f47 100644 --- a/src/main/java/net/bramp/ffmpeg/options/EncodingOptions.java +++ b/src/main/java/net/bramp/ffmpeg/options/EncodingOptions.java @@ -3,6 +3,8 @@ import java.beans.ConstructorProperties; /** + * Audio, Video and Main encoding options for ffmpeg. + * * @author bramp */ public class EncodingOptions { diff --git a/src/main/java/net/bramp/ffmpeg/options/MainEncodingOptions.java b/src/main/java/net/bramp/ffmpeg/options/MainEncodingOptions.java index 8be785d6..86547267 100644 --- a/src/main/java/net/bramp/ffmpeg/options/MainEncodingOptions.java +++ b/src/main/java/net/bramp/ffmpeg/options/MainEncodingOptions.java @@ -3,6 +3,8 @@ import java.beans.ConstructorProperties; /** + * Encoding options that are specific to the main output. + * * @author bramp */ public class MainEncodingOptions { diff --git a/src/main/java/net/bramp/ffmpeg/progress/AbstractSocketProgressParser.java b/src/main/java/net/bramp/ffmpeg/progress/AbstractSocketProgressParser.java index bf174416..e3f3095e 100644 --- a/src/main/java/net/bramp/ffmpeg/progress/AbstractSocketProgressParser.java +++ b/src/main/java/net/bramp/ffmpeg/progress/AbstractSocketProgressParser.java @@ -25,11 +25,11 @@ public AbstractSocketProgressParser(ProgressListener listener) { * *

TODO Move this method to somewhere better. * - * @param scheme - * @param address - * @param port - * @return - * @throws URISyntaxException + * @param scheme The scheme to use (e.g. "tcp", "udp", "rtp", "http") + * @param address The address of the server + * @param port The port to connect to + * @return A URI representing the address and port + * @throws URISyntaxException if the URI is invalid */ @CheckReturnValue static URI createUri(String scheme, InetAddress address, int port) throws URISyntaxException { diff --git a/src/main/java/net/bramp/ffmpeg/progress/Progress.java b/src/main/java/net/bramp/ffmpeg/progress/Progress.java index f43bdc80..e97e133c 100644 --- a/src/main/java/net/bramp/ffmpeg/progress/Progress.java +++ b/src/main/java/net/bramp/ffmpeg/progress/Progress.java @@ -208,7 +208,8 @@ public boolean isEnd() { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (!(o instanceof Progress)) return false; + Progress progress1 = (Progress) o; return frame == progress1.frame && bitrate == progress1.bitrate diff --git a/src/test/java/net/bramp/ffmpeg/FFmpegAvTest.java b/src/test/java/net/bramp/ffmpeg/FFmpegAvTest.java index b287ecf0..10a19178 100644 --- a/src/test/java/net/bramp/ffmpeg/FFmpegAvTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFmpegAvTest.java @@ -39,8 +39,6 @@ public void testVersion() throws Exception { /** * We don't support avconv, so all methods should throw an exception. - * - * @throws IOException */ @Test(expected = IllegalArgumentException.class) public void testProbeVideo() throws IOException { diff --git a/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java b/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java index 72519222..31106c62 100644 --- a/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java @@ -180,10 +180,6 @@ public void testMetaTags() throws InterruptedException, ExecutionException, IOEx /** * Test if addStdoutOutput() actually works, and the output can be correctly captured. - * - * @throws InterruptedException - * @throws ExecutionException - * @throws IOException */ @Test public void testStdout() throws InterruptedException, ExecutionException, IOException { diff --git a/src/test/java/net/bramp/ffmpeg/FFmpegUtilsTest.java b/src/test/java/net/bramp/ffmpeg/FFmpegUtilsTest.java index b13a0474..4993fb1b 100644 --- a/src/test/java/net/bramp/ffmpeg/FFmpegUtilsTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFmpegUtilsTest.java @@ -14,7 +14,7 @@ public void testAbstractUtilsClass() { } @Test - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "InlineMeInliner"}) public void testMillisecondsToString() { assertEquals("00:01:03.123", millisecondsToString(63123)); assertEquals("00:01:03", millisecondsToString(63000)); @@ -24,13 +24,13 @@ public void testMillisecondsToString() { } @Test(expected = IllegalArgumentException.class) - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "InlineMeInliner"}) public void testMillisecondsToStringNegative() { millisecondsToString(-1); } @Test(expected = IllegalArgumentException.class) - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "InlineMeInliner"}) public void testMillisecondsToStringNegativeMinValue() { millisecondsToString(Long.MIN_VALUE); } diff --git a/src/test/java/net/bramp/ffmpeg/Helper.java b/src/test/java/net/bramp/ffmpeg/Helper.java index a1ba24ba..7a8b13bc 100644 --- a/src/test/java/net/bramp/ffmpeg/Helper.java +++ b/src/test/java/net/bramp/ffmpeg/Helper.java @@ -25,9 +25,6 @@ public InputStream apply(@Nullable String input) { /** * Simple wrapper around "new SequenceInputStream", so the user doesn't have to deal with the * horribly dated Enumeration type. - * - * @param input - * @return */ public static InputStream sequenceInputStream(Iterable input) { checkNotNull(input); @@ -41,9 +38,6 @@ public static InputStream loadResource(String name) { /** * Loads all resources, and returns one stream containing them all. - * - * @param names - * @return */ public static InputStream combineResource(List names) { checkNotNull(names); diff --git a/src/test/java/net/bramp/ffmpeg/ReadmeTest.java b/src/test/java/net/bramp/ffmpeg/ReadmeTest.java index 53c81b4f..e2256a43 100644 --- a/src/test/java/net/bramp/ffmpeg/ReadmeTest.java +++ b/src/test/java/net/bramp/ffmpeg/ReadmeTest.java @@ -27,6 +27,7 @@ public class ReadmeTest { public ReadmeTest() throws IOException {} @Test + @SuppressWarnings("unused") public void testCreateFF() throws IOException { FFmpeg ffmpeg = new FFmpeg(FFmpeg.DEFAULT_PATH); FFprobe ffprobe = new FFprobe(FFmpeg.DEFAULT_PATH); diff --git a/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java b/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java index a7a27669..43f49e31 100644 --- a/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java +++ b/src/test/java/net/bramp/ffmpeg/builder/FFmpegBuilderTest.java @@ -17,15 +17,15 @@ import java.net.URI; import java.util.List; import java.util.concurrent.TimeUnit; + +import net.bramp.ffmpeg.builder.FFmpegBuilder.Verbosity; import net.bramp.ffmpeg.options.AudioEncodingOptions; import net.bramp.ffmpeg.options.EncodingOptions; import net.bramp.ffmpeg.options.MainEncodingOptions; import net.bramp.ffmpeg.options.VideoEncodingOptions; import org.junit.Test; -/** - * @author bramp - */ +@SuppressWarnings("unused") public class FFmpegBuilderTest { public FFmpegBuilderTest() throws IOException {} @@ -229,7 +229,6 @@ public void testConflictingVideoSize() { @Test public void testURIOutput() { - List args = new FFmpegBuilder() .setInput("input") diff --git a/src/test/java/net/bramp/ffmpeg/nut/RawHandlerStreamToAudioFormatTest.java b/src/test/java/net/bramp/ffmpeg/nut/RawHandlerStreamToAudioFormatTest.java index 2975f02b..5742172c 100644 --- a/src/test/java/net/bramp/ffmpeg/nut/RawHandlerStreamToAudioFormatTest.java +++ b/src/test/java/net/bramp/ffmpeg/nut/RawHandlerStreamToAudioFormatTest.java @@ -24,7 +24,7 @@ public static List data() { {"ULAW", 48000, 1, 3, new AudioFormat(ULAW, 48000, 8, 3, 3, 48000, false)}, {"PSD\u0008", 48000, 1, 4, new AudioFormat(PCM_SIGNED, 48000, 8, 4, 4, 48000, false)}, {"\u0010DUP", 48000, 1, 6, new AudioFormat(PCM_UNSIGNED, 48000, 16, 6, 12, 48000, true)}, - {"PFD\u0020", 48000, 1, 8, new AudioFormat(PCM_FLOAT, 48000, 32, 8, 32, 48000, false)}, + {"PFD ", 48000, 1, 8, new AudioFormat(PCM_FLOAT, 48000, 32, 8, 32, 48000, false)}, }); } diff --git a/src/test/java/net/bramp/ffmpeg/progress/UdpProgressParserTest.java b/src/test/java/net/bramp/ffmpeg/progress/UdpProgressParserTest.java index bb06fc51..c573e6ec 100644 --- a/src/test/java/net/bramp/ffmpeg/progress/UdpProgressParserTest.java +++ b/src/test/java/net/bramp/ffmpeg/progress/UdpProgressParserTest.java @@ -11,7 +11,6 @@ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.URISyntaxException; -import java.util.List; import net.bramp.ffmpeg.fixtures.Progresses; import org.junit.Test;