From ba52d2d46b4c8fc8ea74a98afa9f606e1f139672 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko <svjatoslav@svjatoslav.eu> Date: Thu, 25 Jun 2015 19:58:50 +0300 Subject: [PATCH] use accessor methods for Encoding Options --- .../meviz/encoder/CommandlineHandler.java | 14 ++-- .../eu/svjatoslav/meviz/encoder/Encoder.java | 10 +-- .../meviz/encoder/EncodingOptions.java | 70 +++++++++++++++++-- .../meviz/encoder/converters/AvconvVideo.java | 4 +- 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java index 1f38b17..d6282c2 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java @@ -65,22 +65,22 @@ public class CommandlineHandler { parser.parse(args); - options.recursive = recursiveParameter.isParameterSpecified(); + options.setRecursive(recursiveParameter.isParameterSpecified()); - options.deinterlace = deinterlaceParameter.isParameterSpecified(); + options.setDeinterlace(deinterlaceParameter.isParameterSpecified()); - options.testOnly = testParameter.isParameterSpecified(); + options.setTestOnly(testParameter.isParameterSpecified()); if (outputFormatParameter.isParameterSpecified()) - options.outputFormats.addAll(outputFormatParameter.getValue()); + options.getOutputFormats().addAll(outputFormatParameter.getValue()); if (workingDirectoryParameter.isParameterSpecified()) - options.workingDirectory = workingDirectoryParameter.getValue(); + options.setWorkingDirectory(workingDirectoryParameter.getValue()); if (inputPatternParameter.isParameterSpecified()) - options.inputPatterns.addAll(inputPatternParameter.getValue()); + options.getInputPatterns().addAll(inputPatternParameter.getValue()); - options.forPortablePlayer = forPortableParameter.isParameterSpecified(); + options.setForPortablePlayer(forPortableParameter.isParameterSpecified()); if (videoBitrateParameter.isParameterSpecified()) options.setVideoBitrate(videoBitrateParameter.getValue()); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java b/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java index 4b56b13..1ec9d03 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java @@ -44,7 +44,7 @@ public class Encoder implements Module { // handle directory for (final File subFile : sourceFile.listFiles()) if (subFile.isDirectory()) { - if (encodingOptions.recursive) + if (encodingOptions.isRecursive()) compileEncodingPlan(subFile); } else compileEncodingPlan(subFile); @@ -58,7 +58,7 @@ public class Encoder implements Module { .getFileExtension(sourceFile); // encode source file into every desired target format - for (final String targetFormat : encodingOptions.outputFormats) { + for (final String targetFormat : encodingOptions.getOutputFormats()) { // construct target file final File targetFile = getTargetFile(sourceFile, @@ -112,7 +112,7 @@ public class Encoder implements Module { public boolean fileMatchesInputPattern(final File file) { final String fileName = file.getName().toLowerCase(); - for (final String inputPattern : encodingOptions.inputPatterns) + for (final String inputPattern : encodingOptions.getInputPatterns()) if (WildCardMatcher.match(fileName, inputPattern.toLowerCase())) return true; @@ -154,9 +154,9 @@ public class Encoder implements Module { encodingPlan = new EncodingPlan(); - compileEncodingPlan(encodingOptions.workingDirectory); + compileEncodingPlan(encodingOptions.getWorkingDirectory()); - if (!encodingOptions.testOnly) + if (!encodingOptions.isTestOnly()) try { encodingPlan.execute(encodingOptions); } catch (final Exception exception) { diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java index 6c666a1..9721cdc 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java @@ -21,19 +21,19 @@ public class EncodingOptions { // public Bitrate audioBitrate; - public boolean deinterlace = false; + private boolean deinterlace = false; - public boolean recursive; + private boolean recursive; - public boolean testOnly; + private boolean testOnly; - public boolean forPortablePlayer = false; + private boolean forPortablePlayer = false; - public File workingDirectory = new File(System.getProperty("user.dir")); + private File workingDirectory = new File(System.getProperty("user.dir")); - List<String> outputFormats = new ArrayList<String>(); + private List<String> outputFormats = new ArrayList<String>(); - List<String> inputPatterns = new ArrayList<String>(); + private List<String> inputPatterns = new ArrayList<String>(); public BitrateParameter.bitrate getAudioBitrate() { return audioBitrate; @@ -51,4 +51,60 @@ public class EncodingOptions { this.videoBitrate = videoBitrate; } + public List<String> getInputPatterns() { + return inputPatterns; + } + + public void setInputPatterns(List<String> inputPatterns) { + this.inputPatterns = inputPatterns; + } + + public List<String> getOutputFormats() { + return outputFormats; + } + + public void setOutputFormats(List<String> outputFormats) { + this.outputFormats = outputFormats; + } + + public File getWorkingDirectory() { + return workingDirectory; + } + + public void setWorkingDirectory(File workingDirectory) { + this.workingDirectory = workingDirectory; + } + + public boolean isForPortablePlayer() { + return forPortablePlayer; + } + + public void setForPortablePlayer(boolean forPortablePlayer) { + this.forPortablePlayer = forPortablePlayer; + } + + public boolean isTestOnly() { + return testOnly; + } + + public void setTestOnly(boolean testOnly) { + this.testOnly = testOnly; + } + + public boolean isRecursive() { + return recursive; + } + + public void setRecursive(boolean recursive) { + this.recursive = recursive; + } + + public boolean isDeinterlace() { + return deinterlace; + } + + public void setDeinterlace(boolean deinterlace) { + this.deinterlace = deinterlace; + } + } diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java index ea4d1d3..3d3393b 100644 --- a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java @@ -37,7 +37,7 @@ public class AvconvVideo extends AbstractConverter { if (audioBitrate != -1) codecParams.append("-b:a " + audioBitrate + "k "); - if (options.deinterlace) + if (options.isDeinterlace()) codecParams.append("-filter:v yadif "); return codecParams.toString(); @@ -94,7 +94,7 @@ public class AvconvVideo extends AbstractConverter { if (options.getAudioBitrate() == bitrate.NONE) audioCodec = null; - if (options.forPortablePlayer) { + if (options.isForPortablePlayer()) { videoBitrate = 1000; audioBitrate = 128; videoCodec = "libxvid"; -- 2.20.1