Skip to content
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 @@ -50,12 +50,14 @@ public Fraction read(JsonReader reader) throws IOException {
String fraction = reader.nextString().trim();

// Ambiguous as to what 0/0 is, but FFmpeg seems to think it's zero
if (zeroByZero != null && fraction.equals("0/0"))
if (zeroByZero != null && "0/0".equals(fraction)) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an argument for being this way around? In English I would say 'does the fraction equal 0/0'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a common Java practice to always put the string literal first to avoid potentialNullPointerException.

return zeroByZero;
}

// Another edge cases is invalid files sometimes output 1/0.
if (divideByZero != null && fraction.endsWith("/0"))
if (divideByZero != null && fraction.endsWith("/0")) {
return divideByZero;
}

return Fraction.getFraction(fraction);
}
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,26 @@ public class FFmpegBuilder {
final static Logger LOG = LoggerFactory.getLogger(FFmpegBuilder.class);

public enum Strict {
VERY, // strictly conform to a older more strict version of the spec or reference software
STRICT, // strictly conform to all the things in the spec no matter what consequences
VERY, // strictly conform to a older more strict version of the specifications or reference software
STRICT, // strictly conform to all the things in the specificiations no matter what consequences
NORMAL, // normal
UNOFFICAL, // allow unofficial extensions
EXPERIMENTAL;

// ffmpeg command line requires these options in the lower case
// ffmpeg command line requires these options in lower case
@Override
public String toString() {
return name().toLowerCase();
}
}

/**
* Log level options : https://ffmpeg.org/ffmpeg.html#Generic-options
* Log level options: https://ffmpeg.org/ffmpeg.html#Generic-options
*/
public enum Verbosity {
QUIET, PANIC, FATAL, ERROR, WARNING, INFO, VERBOSE, DEBUG;

@Override
public String toString() {
return name().toLowerCase();
}
Expand All @@ -67,7 +69,7 @@ public String toString() {
final List<String> extra_args = new ArrayList<>();

// Output
final List<FFmpegOutputBuilder> outputs = new ArrayList<FFmpegOutputBuilder>();
final List<FFmpegOutputBuilder> outputs = new ArrayList<>();

public FFmpegBuilder overrideOutputFiles(boolean override) {
this.override = override;
Expand Down Expand Up @@ -164,10 +166,10 @@ public FFmpegBuilder addExtraArgs(String... values) {


/**
* Create new output file
* Create new output file.
*
* @param filename
* @return A new FFmpegOutputBuilder
* @param filename output file path
* @return A new {@link FFmpegOutputBuilder}
*/
public FFmpegOutputBuilder addOutput(String filename) {
FFmpegOutputBuilder output = new FFmpegOutputBuilder(this, filename);
Expand Down Expand Up @@ -198,7 +200,7 @@ public List<String> build() {
args.add("-v", this.verbosity.toString());

if (startOffset != null) {
args.add("-ss").add(FFmpegUtils.millisecondsToString(startOffset));
args.add("-ss", FFmpegUtils.millisecondsToString(startOffset));
}

if (format != null) {
Expand All @@ -210,20 +212,20 @@ public List<String> build() {
}

if (progress != null) {
args.add("-progress").add(progress.toString());
args.add("-progress", progress.toString());
}

args.addAll(extra_args);

for (String input : inputs) {
args.add("-i").add(input);
args.add("-i", input);
}

if (pass > 0) {
args.add("-pass").add(Integer.toString(pass));
args.add("-pass", Integer.toString(pass));

if (pass_prefix != null) {
args.add("-passlogfile").add(pass_prefix);
args.add("-passlogfile", pass_prefix);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public enum StreamSpecifierType {
StreamSpecifierType(String prefix) {
this.prefix = prefix;
}


@Override
public String toString() {
return prefix;
}
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/bramp/ffmpeg/gson/NamedBitsetAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ protected Optional<Boolean> readBoolean(JsonReader reader) throws IOException {
protected void setField(T target, String name, boolean value) throws IllegalAccessException {
try {
Field f = clazz.getField(name);
if (f.getType().equals(boolean.class)) {
if ((boolean.class.equals(f.getType()))) {
f.setBoolean(target, value);
} else if (f.getType().equals(int.class)) {
} else if (int.class.equals(f.getType())) {
f.setInt(target, value ? 1 : 0);
}

Expand Down Expand Up @@ -80,9 +80,7 @@ public T read(JsonReader reader) throws IOException {
reader.endObject();
return obj;

} catch (InstantiationException e) {
throw new IOException("Reflection error", e);
} catch (IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException e) {
throw new IOException("Reflection error", e);
}
}
Expand All @@ -100,11 +98,9 @@ public void write(JsonWriter writer, T value) throws IOException {
for (Field f : clazz.getFields()) {
try {
boolean b;
if (f.getType().equals(boolean.class)) {

if (boolean.class.equals(f.getType())) {
b = f.getBoolean(value);

} else if (f.getType().equals(int.class)) {
} else if (int.class.equals(f.getType())) {
b = f.getInt(value) != 0;
} else {
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package net.bramp.ffmpeg.progress;

public interface FFmpegProgressListener {
public void progress(Progress p);
void progress(Progress progress);
}
17 changes: 13 additions & 4 deletions src/main/java/net/bramp/ffmpeg/progress/Progress.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@ protected boolean parseLine(String line) {

@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("frame", frame).add("fps", fps)
.add("bitrate", bitrate).add("total_size", total_size).add("out_time_ms", out_time_ms)
.add("dup_frames", dup_frames).add("drop_frames", drop_frames).add("speed", speed)
.add("progress", progress).toString();
return MoreObjects.toStringHelper(this)
// @formatter:off
.add("frame", frame)
.add("fps", fps)
.add("bitrate", bitrate)
.add("total_size", total_size)
.add("out_time_ms", out_time_ms)
.add("dup_frames", dup_frames)
.add("drop_frames", drop_frames)
.add("speed", speed)
.add("progress", progress)
// @formatter:on
.toString();
}
}