options.forPortablePlayer = forPortableParameter.isParameterSpecified();
if (videoBitrateParameter.isParameterSpecified())
- try {
- options.setVideoBitrate(videoBitrateParameter.getValue());
- } catch (final Exception e) {
- System.out
- .println("Invalid video bitrate. Valid values are: LOW, MEDIUM, HIGH.");
- return null;
- }
+ options.setVideoBitrate(videoBitrateParameter.getValue());
+
+ if (audioBitrateParameter.isParameterSpecified())
+ options.setAudioBitrate(audioBitrateParameter.getValue());
return options;
}
import java.io.File;
import java.util.List;
+import eu.svjatoslav.meviz.encoder.BitrateParameter;
import eu.svjatoslav.meviz.encoder.BitrateParameter.bitrate;
import eu.svjatoslav.meviz.encoder.EncodingOptions;
codecParams.append("-filter:v yadif ");
}
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- int videoBitrate = -1;
- int audioBitrate = -1;
-
- switch (options.getVideoBitrate()) {
+ private int getAudioBitrateValue(final BitrateParameter.bitrate bitRate) {
+ switch (bitRate) {
case LOW:
- videoBitrate = 1000;
- audioBitrate = 128;
- break;
+ return 128;
case MEDIUM:
- videoBitrate = 4000;
- audioBitrate = 192;
- break;
+ return 160;
case HIGH:
- videoBitrate = 40000;
- audioBitrate = 500;
- break;
+ return 320;
case COPY:
- break;
+ return -1;
default:
- throw new RuntimeException("Video bitrate: " + options.getVideoBitrate()
+ throw new RuntimeException("Audio bitrate: " + bitRate
+ " is not supported.");
}
+ }
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+
+ int videoBitrate = getVideoBitrateValue(options.getVideoBitrate());
+ int audioBitrate = getAudioBitrateValue(options.getAudioBitrate());
// convert
final StringBuffer codecParams = new StringBuffer();
String videoCodec = "libx264";
String audioCodec = "libmp3lame";
- if (options.getVideoBitrate() == bitrate.COPY) {
+ if (options.getVideoBitrate() == bitrate.COPY)
videoCodec = "copy";
+
+ if (options.getAudioBitrate() == bitrate.COPY)
audioCodec = "copy";
- }
if (options.forPortablePlayer) {
videoBitrate = 1000;
return toList("mkv", "mts", "mp4", "avi", "mpg", "mpeg", "vob", "m4v");
}
+ private int getVideoBitrateValue(final BitrateParameter.bitrate bitRate) {
+ switch (bitRate) {
+ case LOW:
+ return 1000;
+
+ case MEDIUM:
+ return 4000;
+
+ case HIGH:
+ return 40000;
+
+ case COPY:
+ return -1;
+
+ default:
+ throw new RuntimeException("Video bitrate: " + bitRate
+ + " is not supported.");
+ }
+ }
+
@Override
public boolean isTerminalMandatory() {
return true;