Now single converter supports multiple source and target extensions.
import eu.svjatoslav.commons.file.FilePathParser;
import eu.svjatoslav.commons.string.WildCardMatcher;
import eu.svjatoslav.meviz.Module;
-import eu.svjatoslav.meviz.encoder.converters.Converter;
+import eu.svjatoslav.meviz.encoder.converters.AbstractConverter;
public class Encoder implements Module {
if (!targetFile.exists()) {
- final List<eu.svjatoslav.meviz.encoder.converters.Converter> formats = encoderRegistry
+ final List<eu.svjatoslav.meviz.encoder.converters.AbstractConverter> formats = encoderRegistry
.getEncoders(sourceFileExtension, targetFormat);
if (formats.size() == 0)
+ targetFormat
+ " format.");
else {
- final Converter chosenFormat = formats.get(0);
+ final AbstractConverter chosenFormat = formats.get(0);
final EncodingTask encodingTask = new EncodingTask(
sourceFile, targetFile, chosenFormat);
import java.io.File;
-import eu.svjatoslav.meviz.encoder.converters.Converter;
+import eu.svjatoslav.meviz.encoder.converters.AbstractConverter;
public class EncodingTask {
*/
private final File target;
- private final Converter converter;
+ private final AbstractConverter converter;
private boolean useTerminal;
public EncodingTask(final File source, final File destination,
- final eu.svjatoslav.meviz.encoder.converters.Converter converter) {
+ final eu.svjatoslav.meviz.encoder.converters.AbstractConverter converter) {
this.source = source;
target = destination;
import java.util.ArrayList;
import java.util.List;
-import eu.svjatoslav.meviz.encoder.converters.Avi2Ogv;
-import eu.svjatoslav.meviz.encoder.converters.Converter;
-import eu.svjatoslav.meviz.encoder.converters.Jpeg2Png;
-import eu.svjatoslav.meviz.encoder.converters.Mkv2Mp4;
-import eu.svjatoslav.meviz.encoder.converters.Mp42Ogv;
-import eu.svjatoslav.meviz.encoder.converters.Mts2Mkv;
-import eu.svjatoslav.meviz.encoder.converters.Mts2Mp4;
-import eu.svjatoslav.meviz.encoder.converters.Ogg2Mp3;
+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.Png2Tiff;
-import eu.svjatoslav.meviz.encoder.converters.Tif2Png;
-import eu.svjatoslav.meviz.encoder.converters.Tiff2Png;
-import eu.svjatoslav.meviz.encoder.converters.Wav2flac;
-import eu.svjatoslav.meviz.encoder.converters.Wav2mp3;
+import eu.svjatoslav.meviz.encoder.converters.Convert;
+import eu.svjatoslav.meviz.encoder.converters.Flac;
public class FormatsRegistry {
- public ArrayList<Converter> encoders = new ArrayList<Converter>();
+ public ArrayList<AbstractConverter> encoders = new ArrayList<AbstractConverter>();
public FormatsRegistry() {
// video conversion
- registerEncoder(new Avi2Ogv());
- registerEncoder(new Mp42Ogv());
- registerEncoder(new Mts2Mp4());
- registerEncoder(new Mts2Mkv());
- registerEncoder(new Mkv2Mp4());
+ registerEncoder(new Ffmpeg2theora());
+ registerEncoder(new Ffmpeg());
+ registerEncoder(new AvconvVideo());
// image conversion
- registerEncoder(new Jpeg2Png());
- registerEncoder(new Png2Tiff());
- registerEncoder(new Tiff2Png());
- registerEncoder(new Tif2Png());
+ registerEncoder(new Convert());
// audio conversion
registerEncoder(new Ogg2Wav());
- registerEncoder(new Wav2mp3());
- registerEncoder(new Wav2flac());
- registerEncoder(new Ogg2Mp3());
+ registerEncoder(new Flac());
+ registerEncoder(new AvconvAudio());
}
- public List<Converter> getEncoders(final String sourceFormat,
+ public List<AbstractConverter> getEncoders(final String sourceFormat,
final String targetFormat) {
final String sourceFormatLowerCase = sourceFormat.toLowerCase();
final String targetFormatLowerCase = targetFormat.toLowerCase();
- final ArrayList<Converter> encoders = new ArrayList<Converter>();
+ final ArrayList<AbstractConverter> encoders = new ArrayList<AbstractConverter>();
- for (final Converter encoder : this.encoders)
- if (encoder.getSourceFileExtension().equals(sourceFormatLowerCase))
- if (encoder.getTargetFileExtension().equals(
- targetFormatLowerCase)) {
+ for (final AbstractConverter encoder : this.encoders)
+ if (encoder.supportsSource(sourceFormatLowerCase))
+ if (encoder.supportsTarget(targetFormatLowerCase)) {
encoders.add(encoder);
return encoders;
}
return encoders;
}
- public void registerEncoder(final Converter encoder) {
+ public void registerEncoder(final AbstractConverter encoder) {
encoders.add(encoder);
}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public abstract class AbstractConverter {
+
+ public abstract String getCommand(File inputFile, File targetFile,
+ EncodingOptions options);
+
+ public abstract List<String> getSourceFileExtensions();
+
+ public abstract List<String> getTargetFileExtensions();
+
+ /**
+ * For some reasons some encoders require terminal to run. Until this is
+ * resolved, encoder can request for terminal using this method.
+ */
+ public abstract boolean isTerminalMandatory();
+
+ public boolean supportsSource(final String format) {
+ return getSourceFileExtensions().contains(format);
+ }
+
+ public boolean supportsTarget(final String format) {
+ return getTargetFileExtensions().contains(format);
+ }
+
+ public List<String> toList(final String... strings) {
+ final ArrayList<String> result = new ArrayList<String>();
+
+ for (final String string : strings)
+ result.add(string);
+
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class AvconvAudio extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+
+ final String codecParams = "-b:a 192k";
+
+ return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
+ + codecParams + " \"" + targetFile.getAbsolutePath() + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("ogg", "wav");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("mp3");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return false;
+ }
+
+}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class AvconvVideo extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+
+ int videoBitrate;
+ int audioBitrate;
+
+ switch (options.videoBitrate) {
+ case LOW:
+ videoBitrate = 1000;
+ audioBitrate = 128;
+ break;
+
+ case MEDIUM:
+ videoBitrate = 3500;
+ audioBitrate = 128;
+ break;
+
+ case HIGH:
+ videoBitrate = 40000;
+ audioBitrate = 500;
+ break;
+
+ default:
+ throw new RuntimeException("Video bitrate: " + options.videoBitrate
+ + " is not supported.");
+ }
+
+ // convert
+ final StringBuffer codecParams = new StringBuffer();
+
+ codecParams.append("-acodec libmp3lame -vcodec libx264");
+
+ codecParams.append(" -b " + videoBitrate + "k");
+ codecParams.append(" -b:a " + audioBitrate + "k");
+
+ if (options.deinterlace)
+ codecParams.append(" -filter:v yadif");
+
+ return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
+ + codecParams.toString() + " \"" + targetFile.getAbsolutePath()
+ + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("mkv", "mts");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("mp4");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return true;
+ }
+
+}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Avi2Ogv implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- return "ffmpeg2theora \"" + inputFile.getAbsolutePath() + "\" -o \""
- + targetFile.getAbsolutePath()
- + "\" --optimize --videobitrate 3000 --width 800";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "avi";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "ogv";
- }
-
- @Override
- public boolean isTerminalMandatory() {
-
- return false;
- }
-
-}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class Convert extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+ return "convert \"" + inputFile.getAbsolutePath() + "\" \""
+ + targetFile.getAbsolutePath() + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("tif", "tiff", "jpg", "jpeg");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("png", "tiff");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return false;
+ }
+
+}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public interface Converter {
-
- public String getCommand(File inputFile, File targetFile, EncodingOptions options);
-
- public String getSourceFileExtension();
-
- public String getTargetFileExtension();
-
- /**
- * For some reasons some encoders require terminal to run. Until this is
- * resolved, encoder can request for terminal using this method.
- */
- public boolean isTerminalMandatory();
-}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class Ffmpeg extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+
+ return "ffmpeg -i \"" + inputFile.getAbsolutePath()
+ + "\" -vcodec copy -acodec copy \""
+ + targetFile.getAbsolutePath() + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("mts");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("mkv");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return true;
+ }
+
+}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class Ffmpeg2theora extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+ return "ffmpeg2theora \"" + inputFile.getAbsolutePath() + "\" -o \""
+ + targetFile.getAbsolutePath()
+ + "\" --optimize --videobitrate 3000 --width 800";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("avi", "mp4");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("ogv");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return true;
+ }
+
+}
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia.
+ * Copyright (C) 2012, 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
+ * as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import java.io.File;
+import java.util.List;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+public class Flac extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
+
+ return "flac -8 \"" + inputFile.getAbsolutePath() + "\" -o \""
+ + targetFile.getAbsolutePath() + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("wav");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("flac");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return false;
+ }
+
+}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Jpeg2Png implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
- return "convert \"" + inputFile.getAbsolutePath() + "\" \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "jpeg";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "png";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Mkv2Mp4 implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- int videoBitrate;
- int audioBitrate;
-
- switch (options.videoBitrate) {
- case LOW:
- videoBitrate = 1000;
- audioBitrate = 128;
- break;
-
- case MEDIUM:
- videoBitrate = 3500;
- audioBitrate = 128;
- break;
-
- case HIGH:
- videoBitrate = 15000;
- audioBitrate = 500;
- break;
-
- default:
- throw new RuntimeException("Video bitrate: " + options.videoBitrate
- + " is not supported.");
- }
-
- // convert
- final StringBuffer codecParams = new StringBuffer();
-
- codecParams.append("-acodec libmp3lame -vcodec libx264");
-
- codecParams.append(" -b " + videoBitrate + "k");
- codecParams.append(" -b:a " + audioBitrate + "k");
-
- if (options.deinterlace) {
- codecParams.append(" -filter:v yadif");
- }
-
- return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
- + codecParams.toString() + " \"" + targetFile.getAbsolutePath()
- + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "mkv";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "mp4";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return true;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Mp42Ogv implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
- return "ffmpeg2theora \"" + inputFile.getAbsolutePath() + "\" -o \"" + targetFile.getAbsolutePath()
- + "\" --optimize --videobitrate 3000 --width 800";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "mp4";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "ogv";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return true;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Mts2Mkv implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
-
- return "ffmpeg -i \"" + inputFile.getAbsolutePath() + "\" -vcodec copy -acodec copy \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "mts";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "mkv";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return true;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-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 {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- int videoBitrate = 0;
- int audioBitrate = 0;
-
- switch (options.videoBitrate) {
- case LOW:
- videoBitrate = 1000;
- audioBitrate = 128;
- break;
-
- case MEDIUM:
- videoBitrate = 3500;
- audioBitrate = 128;
- break;
-
- case HIGH:
- videoBitrate = 15000;
- audioBitrate = 500;
- break;
-
- case COPY:
- break;
-
- default:
- throw new RuntimeException("Video bitrate: " + options.videoBitrate
- + " is not supported.");
- }
-
- // convert
- final StringBuffer codecParams = new StringBuffer();
-
- if (options.videoBitrate == BitrateParameter.bitrate.COPY) {
- // pass through
- codecParams.append("-acodec copy -vcodec copy");
-
- } else {
- codecParams.append("-acodec libmp3lame -vcodec libx264");
- codecParams.append(" -b " + videoBitrate + "k");
- codecParams.append(" -b:a " + audioBitrate + "k");
- }
-
- if (options.deinterlace) {
- codecParams.append(" -filter:v yadif");
- }
-
- return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
- + codecParams.toString() + " \"" + targetFile.getAbsolutePath()
- + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "mts";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "mp4";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return true;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Ogg2Mp3 implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
- return "avconv -i \"" + inputFile.getAbsolutePath() + "\" \"" + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "ogg";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "mp3";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
package eu.svjatoslav.meviz.encoder.converters;
import java.io.File;
+import java.util.List;
import eu.svjatoslav.meviz.encoder.EncodingOptions;
-public class Ogg2Wav implements Converter {
+public class Ogg2Wav extends AbstractConverter {
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options) {
- return "oggdec \"" + inputFile.getAbsolutePath() + "\" -o \"" + targetFile.getAbsolutePath() + "\"";
+ return "oggdec \"" + inputFile.getAbsolutePath() + "\" -o \""
+ + targetFile.getAbsolutePath() + "\"";
- }
+ }
- @Override
- public String getSourceFileExtension() {
- return "ogg";
- }
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("ogg");
+ }
- @Override
- public String getTargetFileExtension() {
- return "wav";
- }
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("wav");
+ }
- @Override
- public boolean isTerminalMandatory() {
- return true;
- }
+ @Override
+ public boolean isTerminalMandatory() {
+ return true;
+ }
}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Png2Tiff implements Converter {
-
-
- @Override
- public String getCommand(final File inputFile, final File targetFile, final EncodingOptions options) {
- return "convert \"" + inputFile.getAbsolutePath() + "\" \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "tiff";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "png";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Tif2Png implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
- return "convert \"" + inputFile.getAbsolutePath() + "\" \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "tif";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "png";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Tiff2Png implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
- return "convert \"" + inputFile.getAbsolutePath() + "\" \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "tiff";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "png";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Wav2flac implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- return "flac -8 \"" + inputFile.getAbsolutePath() + "\" -o \""
- + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "wav";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "flac";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, 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
- * as published by the Free Software Foundation.
- */
-
-package eu.svjatoslav.meviz.encoder.converters;
-
-import java.io.File;
-
-import eu.svjatoslav.meviz.encoder.EncodingOptions;
-
-public class Wav2mp3 implements Converter {
-
- @Override
- public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
-
- final String codecParams = "-b:a 192k";
-
- return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
- + codecParams + " \"" + targetFile.getAbsolutePath() + "\"";
- }
-
- @Override
- public String getSourceFileExtension() {
- return "wav";
- }
-
- @Override
- public String getTargetFileExtension() {
- return "mp3";
- }
-
- @Override
- public boolean isTerminalMandatory() {
- return false;
- }
-
-}
import eu.svjatoslav.meviz.encoder.EncodingOptions;
import eu.svjatoslav.meviz.encoder.EncodingPlan;
import eu.svjatoslav.meviz.encoder.EncodingTask;
-import eu.svjatoslav.meviz.encoder.converters.Converter;
-import eu.svjatoslav.meviz.encoder.converters.Mts2Mp4;
+import eu.svjatoslav.meviz.encoder.converters.AbstractConverter;
+import eu.svjatoslav.meviz.encoder.converters.Ffmpeg;
public class Main implements Module {
+ "/AVCHD/BDMV/STREAM/";
final File videosDirectory = new File(videosPath);
- if (!videosDirectory.exists()) {
+ if (!videosDirectory.exists())
return new File[0];
- }
return videosDirectory.listFiles();
}
public String getDoubleDigit(final int value) {
String valueString = Integer.toString(value);
- if (valueString.length() == 1) {
+ if (valueString.length() == 1)
valueString = "0" + valueString;
- }
return valueString;
};
final File targetDirectory = getTargetDirectory();
targetDirectory.mkdirs();
- final Converter converter = new Mts2Mp4();
+ final AbstractConverter converter = new Ffmpeg();
final EncodingPlan encodingPlan = new EncodingPlan();
final String userName = System.getProperty("user.name");