From: Svjatoslav Agejenko <svjatoslav@svjatoslav.eu> Date: Tue, 31 Dec 2013 14:25:14 +0000 (+0200) Subject: possibility to quickly encode video for portable players X-Git-Tag: meviz-1.0~61 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=64e6f0bfee5ada06170af9f01cc3d8ec42216ef5;p=meviz.git possibility to quickly encode video for portable players --- diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java index b6e10ce..ba54599 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java @@ -31,6 +31,9 @@ public class CommandlineHandler { NullParameter recursiveParameter = parser.createNullParameter( "Enable recursive mode.").addAliases("-r", "--recursive"); + NullParameter forPortableParameter = parser.createNullParameter( + "Encode for portable player.").addAliases("-p", "--portable"); + StringParameter inputPatternParameter = parser .createStringParameter("File input pattern.") .addAliases("-i", "--input-pattern").setMandatory(); @@ -58,14 +61,11 @@ public class CommandlineHandler { parser.parse(args); - if (recursiveParameter.isParameterSpecified()) - options.recursive = true; + options.recursive = recursiveParameter.isParameterSpecified(); - if (deinterlaceParameter.isParameterSpecified()) - options.deinterlace = true; + options.deinterlace = deinterlaceParameter.isParameterSpecified(); - if (testParameter.isParameterSpecified()) - options.testOnly = true; + options.testOnly = testParameter.isParameterSpecified(); if (outputFormatParameter.isParameterSpecified()) options.outputFormats.addAll(outputFormatParameter @@ -79,6 +79,8 @@ public class CommandlineHandler { options.inputPatterns.addAll(inputPatternParameter .getArgumentsAsStrings()); + options.forPortablePlayer = forPortableParameter.isParameterSpecified(); + if (videoBitrateParameter.isParameterSpecified()) try { options.videoBitrate = videoBitrateParameter.getValue(); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java index 463b48a..9e7f2b4 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java @@ -25,6 +25,8 @@ public class EncodingOptions { public boolean testOnly; + public boolean forPortablePlayer = false; + public File workingDirectory = new File(System.getProperty("user.dir")); List<String> outputFormats = new ArrayList<String>(); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java index 0d8bc8e..2d6a788 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java @@ -12,14 +12,14 @@ package eu.svjatoslav.meviz.encoder; import java.util.ArrayList; import java.util.List; -import eu.svjatoslav.meviz.encoder.converters.Ffmpeg2theora; import eu.svjatoslav.meviz.encoder.converters.AbstractConverter; -import eu.svjatoslav.meviz.encoder.converters.AvconvVideo; -import eu.svjatoslav.meviz.encoder.converters.Ffmpeg; import eu.svjatoslav.meviz.encoder.converters.AvconvAudio; -import eu.svjatoslav.meviz.encoder.converters.Ogg2Wav; +import eu.svjatoslav.meviz.encoder.converters.AvconvVideo; import eu.svjatoslav.meviz.encoder.converters.Convert; +import eu.svjatoslav.meviz.encoder.converters.Ffmpeg; +import eu.svjatoslav.meviz.encoder.converters.Ffmpeg2theora; import eu.svjatoslav.meviz.encoder.converters.Flac; +import eu.svjatoslav.meviz.encoder.converters.Ogg2Wav; public class FormatsRegistry { diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java index c63837a..de295ca 100644 --- a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java @@ -47,27 +47,36 @@ public class AvconvVideo extends AbstractConverter { // convert final StringBuffer codecParams = new StringBuffer(); - codecParams.append("-acodec libmp3lame -vcodec libx264"); + String videoCodec = "libx264 "; - codecParams.append(" -b " + videoBitrate + "k"); - codecParams.append(" -b:a " + audioBitrate + "k"); + if (options.forPortablePlayer) { + videoBitrate = 1000; + audioBitrate = 128; + 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"); + codecParams.append("-filter:v yadif "); return "avconv -i \"" + inputFile.getAbsolutePath() + "\" " - + codecParams.toString() + " \"" + targetFile.getAbsolutePath() + + codecParams.toString() + "\"" + targetFile.getAbsolutePath() + "\""; } @Override public List<String> getSourceFileExtensions() { - return toList("mkv", "mts"); + return toList("mkv", "mts", "mp4", "avi"); } @Override public List<String> getTargetFileExtensions() { - return toList("mp4"); + return toList("mkv", "mts", "mp4", "avi"); } @Override