possibility to use stream COPY
[meviz.git] / src / main / java / eu / svjatoslav / meviz / encoder / converters / Mts2Mp4.java
index 9ea8da7..9af415f 100755 (executable)
@@ -11,6 +11,7 @@ package eu.svjatoslav.meviz.encoder.converters;
 
 import java.io.File;
 
+import eu.svjatoslav.meviz.encoder.BitrateParameter;
 import eu.svjatoslav.meviz.encoder.EncodingOptions;
 
 public class Mts2Mp4 implements Converter {
@@ -19,8 +20,8 @@ public class Mts2Mp4 implements Converter {
        public String getCommand(final File inputFile, final File targetFile,
                        final EncodingOptions options) {
 
-               int videoBitrate;
-               int audioBitrate;
+               int videoBitrate = 0;
+               int audioBitrate = 0;
 
                switch (options.videoBitrate) {
                case LOW:
@@ -38,6 +39,9 @@ public class Mts2Mp4 implements Converter {
                        audioBitrate = 500;
                        break;
 
+               case COPY:
+                       break;
+
                default:
                        throw new RuntimeException("Video bitrate: " + options.videoBitrate
                                        + " is not supported.");
@@ -46,16 +50,19 @@ public class Mts2Mp4 implements Converter {
                // convert
                final StringBuffer codecParams = new StringBuffer();
 
-               codecParams.append("-acodec libmp3lame -vcodec libx264");
+               if (options.videoBitrate == BitrateParameter.bitrate.COPY) {
+                       // pass through
+                       codecParams.append("-acodec copy -vcodec copy");
 
-               codecParams.append(" -b " + videoBitrate + "k");
-               codecParams.append(" -b:a " + audioBitrate + "k");
+               } else {
+                       codecParams.append("-acodec libmp3lame -vcodec libx264");
+                       codecParams.append(" -b " + videoBitrate + "k");
+                       codecParams.append(" -b:a " + audioBitrate + "k");
+               }
 
-               if (options.deinterlace)
+               if (options.deinterlace) {
                        codecParams.append(" -filter:v yadif");
-
-               // pass through
-               // final String codecParams = "-acodec copy -vcodec copy";
+               }
 
                return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
                                + codecParams.toString() + " \"" + targetFile.getAbsolutePath()