import java.io.File;
import java.util.List;
+import eu.svjatoslav.meviz.encoder.BitrateParameter.bitrate;
import eu.svjatoslav.meviz.encoder.EncodingOptions;
public class AvconvVideo extends AbstractConverter {
+ private void constructCodecParamsString(final EncodingOptions options,
+ final int videoBitrate, final int audioBitrate,
+ final StringBuffer codecParams, final String videoCodec,
+ final String audioCodec) {
+
+ codecParams.append("-acodec " + audioCodec + " -vcodec " + videoCodec
+ + " ");
+
+ if (videoBitrate != -1)
+ codecParams.append("-b " + videoBitrate + "k ");
+
+ if (audioBitrate != -1)
+ codecParams.append("-b:a " + audioBitrate + "k ");
+
+ if (options.deinterlace)
+ codecParams.append("-filter:v yadif ");
+ }
+
@Override
public String getCommand(final File inputFile, final File targetFile,
final EncodingOptions options) {
- int videoBitrate;
- int audioBitrate;
+ int videoBitrate = -1;
+ int audioBitrate = -1;
switch (options.videoBitrate) {
case LOW:
audioBitrate = 500;
break;
+ case COPY:
+ break;
+
default:
throw new RuntimeException("Video bitrate: " + options.videoBitrate
+ " is not supported.");
// convert
final StringBuffer codecParams = new StringBuffer();
- String videoCodec = "libx264 ";
+ String videoCodec = "libx264";
+ String audioCodec = "libmp3lame";
+
+ if (options.videoBitrate == bitrate.COPY) {
+ videoCodec = "copy";
+ audioCodec = "copy";
+ }
if (options.forPortablePlayer) {
videoBitrate = 1000;
audioBitrate = 128;
- videoCodec = "libxvid ";
+ videoCodec = "libxvid";
codecParams.append("-s 640x480 ");
}
- codecParams.append("-acodec libmp3lame -vcodec " + videoCodec);
-
- codecParams.append("-b " + videoBitrate + "k ");
- codecParams.append("-b:a " + audioBitrate + "k ");
-
- if (options.deinterlace)
- codecParams.append("-filter:v yadif ");
+ constructCodecParamsString(options, videoBitrate, audioBitrate,
+ codecParams, videoCodec, audioCodec);
return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
- + codecParams.toString() + "\"" + targetFile.getAbsolutePath()
- + "\"";
+ + codecParams.toString() + "\"" + targetFile.getAbsolutePath()
+ + "\"";
}
@Override