import eu.svjatoslav.commons.commandline.parameterparser.Parser;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter;
+import eu.svjatoslav.commons.commandline.parameterparser.parameter.IntegerParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters;
.add(new StringParameters("Encoding output format."))
.addAliases("-o", "--output-format").setMandatory();
+ IntegerParameter targetFramerate = parser.add(new IntegerParameter(
+ "Target framerate.").addAliases("-f", "--target-frame"));
+
NullParameter deinterlaceParameter = parser.add(
- new NullParameter("Deinterlace video.")).addAliases(
- "--deinterlace", "-d");
+ new NullParameter("Deinterlace video.")).addAliases("-d",
+ "--deinterlace");
NullParameter testParameter = parser.add(
new NullParameter("Simulate file encoding.")).addAliases("-t",
if (outputFormatParameter.isParameterSpecified())
options.getOutputFormats().addAll(outputFormatParameter.getValue());
+ if (targetFramerate.isParameterSpecified())
+ options.setTargetFps(targetFramerate.getValue());
+
if (workingDirectoryParameter.isParameterSpecified())
options.setWorkingDirectory(workingDirectoryParameter.getValue());
if (inputPatternParameter.isParameterSpecified())
options.getInputPatterns().addAll(inputPatternParameter.getValue());
- options.setForPortablePlayer(forPortableParameter.isParameterSpecified());
+ options.setForPortablePlayer(forPortableParameter
+ .isParameterSpecified());
if (videoBitrateParameter.isParameterSpecified())
options.setVideoBitrate(videoBitrateParameter.getValue());
/*
* Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2012-2015, 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
private BitrateParameter.bitrate audioBitrate = BitrateParameter.bitrate.MEDIUM;
- // public Bitrate audioBitrate;
+ private Integer targetFps;
private boolean deinterlace = false;
return audioBitrate;
}
- public BitrateParameter.bitrate getVideoBitrate() {
- return videoBitrate;
- }
-
- public void setAudioBitrate(final BitrateParameter.bitrate audioBitrate) {
- this.audioBitrate = audioBitrate;
- }
-
- public void setVideoBitrate(final BitrateParameter.bitrate videoBitrate) {
- 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 Integer getTargetFps() {
+ return targetFps;
+ }
+
+ public BitrateParameter.bitrate getVideoBitrate() {
+ return videoBitrate;
}
public File getWorkingDirectory() {
return workingDirectory;
}
- public void setWorkingDirectory(File workingDirectory) {
- this.workingDirectory = workingDirectory;
+ public boolean isDeinterlace() {
+ return deinterlace;
}
public boolean isForPortablePlayer() {
return forPortablePlayer;
}
- public void setForPortablePlayer(boolean forPortablePlayer) {
- this.forPortablePlayer = forPortablePlayer;
+ public boolean isRecursive() {
+ return recursive;
}
public boolean isTestOnly() {
return testOnly;
}
- public void setTestOnly(boolean testOnly) {
- this.testOnly = testOnly;
+ public void setAudioBitrate(final BitrateParameter.bitrate audioBitrate) {
+ this.audioBitrate = audioBitrate;
}
- public boolean isRecursive() {
- return recursive;
+ public void setDeinterlace(final boolean deinterlace) {
+ this.deinterlace = deinterlace;
+ }
+
+ public void setForPortablePlayer(final boolean forPortablePlayer) {
+ this.forPortablePlayer = forPortablePlayer;
+ }
+
+ public void setInputPatterns(final List<String> inputPatterns) {
+ this.inputPatterns = inputPatterns;
+ }
+
+ public void setOutputFormats(final List<String> outputFormats) {
+ this.outputFormats = outputFormats;
}
- public void setRecursive(boolean recursive) {
+ public void setRecursive(final boolean recursive) {
this.recursive = recursive;
}
- public boolean isDeinterlace() {
- return deinterlace;
+ public void setTargetFps(final Integer targetFps) {
+ this.targetFps = targetFps;
}
- public void setDeinterlace(boolean deinterlace) {
- this.deinterlace = deinterlace;
+ public void setTestOnly(final boolean testOnly) {
+ this.testOnly = testOnly;
+ }
+
+ public void setVideoBitrate(final BitrateParameter.bitrate videoBitrate) {
+ this.videoBitrate = videoBitrate;
+ }
+
+ public void setWorkingDirectory(final File workingDirectory) {
+ this.workingDirectory = workingDirectory;
}
}
final int videoBitrate, final int audioBitrate,
final String videoCodec, final String audioCodec) {
- StringBuffer codecParams = new StringBuffer();
+ final StringBuffer codecParams = new StringBuffer();
if (audioCodec == null)
codecParams.append("-an ");
if (options.isDeinterlace())
codecParams.append("-filter:v yadif ");
+ if (options.getTargetFps() != null)
+ codecParams.append("-r " + options.getTargetFps() + " ");
+
return codecParams.toString();
}
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options, String targetFormat) {
+ final EncodingOptions options, final String targetFormat) {
int videoBitrate = getVideoBitrateValue(options.getVideoBitrate());
int audioBitrate = getAudioBitrateValue(options.getAudioBitrate());
return 4000;
case HIGH:
- return 40000;
+ return 16000;
case COPY:
return -1;