+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder;
-
-import eu.svjatoslav.commons.commandline.parameterparser.Argument;
-
-public class Bitrate implements Argument {
- @Override
- public String describeFormat() {
- return "Target bitrate [LOW / MEDIUM / HIGH]";
- }
-
- @Override
- public boolean validate(final String value) {
- try {
- bitrate.valueOf(value);
- } catch (final IllegalArgumentException exception) {
- return false;
- }
-
- return true;
- }
-
- static public enum bitrate {
- LOW, MEDIUM, HIGH
- };
-
-}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder;
+
+import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
+import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
+
+public class BitrateParameter extends Parameter {
+
+ public BitrateParameter(String description) {
+ super(description, ArgumentCount.SINGLE);
+ }
+
+ @Override
+ public String describeFormat() {
+ return "Target bitrate [LOW / MEDIUM / HIGH]";
+ }
+
+ @Override
+ public boolean validate(final String value) {
+ try {
+ bitrate.valueOf(value);
+ } catch (final IllegalArgumentException exception) {
+ return false;
+ }
+
+ return true;
+ }
+
+ static public enum bitrate {
+ LOW, MEDIUM, HIGH
+ };
+
+ public bitrate getValue() {
+ return bitrate.valueOf(getArgumentsAsStrings().get(0).toUpperCase());
+ }
+}
package eu.svjatoslav.meviz.encoder;
-import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
import eu.svjatoslav.commons.commandline.parameterparser.Parser;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
.createDirectoryParameter("Working directory.")
.addAliases("-w", "--working-directory").mustExist();
- Parameter videoBitrateParameter = parser.createCustomParameter(
- new Bitrate(), "Video bitrate.")
- .addAliases("-v", "--video-bitrate");
-
- public Parser initParser() {
- final Parser parser = new Parser();
-
- parser.addParameter(recursiveParameter);
-
- parser.addParameter(deinterlaceParameter);
-
- parser.addParameter(testParameter);
-
- parser.addParameter(terminalParameter);
-
- parser.addParameter(outputFormatParameter);
-
- parser.addParameter(inputPatternParameter);
-
- parser.addParameter(workingDirectoryParameter);
+ BitrateParameter videoBitrateParameter = new BitrateParameter(
+ "Video bitrate");
+ public CommandlineHandler() {
+ videoBitrateParameter.addAliases("-v", "--video-bitrate");
parser.addParameter(videoBitrateParameter);
-
- return parser;
}
/**
final EncodingOptions options = new EncodingOptions();
- final Parser parser = initParser();
parser.parse(args);
if (recursiveParameter.isParameterSpecified())
if (videoBitrateParameter.isParameterSpecified())
try {
- options.videoBitrate = Bitrate.bitrate
- .valueOf(videoBitrateParameter.getArgumentsAsStrings()
- .get(0).toUpperCase());
+ options.videoBitrate = videoBitrateParameter.getValue();
} catch (final Exception e) {
System.out
.println("Invalid video bitrate. Valid values are: LOW, MEDIUM, HIGH.");
@Override
public void showCommandlineHelp() {
- commandlineHandler.initParser().showHelp();
+ commandlineHandler.parser.showHelp();
System.out.println("Example commands:");
System.out
.println(" Convert all MTS files in the current directory into MP4's.");
public class EncodingOptions {
- public Bitrate.bitrate videoBitrate = Bitrate.bitrate.MEDIUM;
+ public BitrateParameter.bitrate videoBitrate = BitrateParameter.bitrate.MEDIUM;
// public Bitrate audioBitrate;