public interface Module {
- public String getDescription();
+ public String getDescription();
- public String getModuleCommand();
+ public String getModuleCommand();
- public void run(String args[]) throws Exception;
+ public void run(String args[]) throws Exception;
- public void showCommandlineHelp();
+ public void showCommandlineHelp();
}
StringParameters inputPatternParameter = parser.add(
new StringParameters("File input pattern.")).addAliases("-i",
- "--input-pattern");
+ "--input-pattern");
DirectoryParameter workingDirectoryParameter = parser
.add(new DirectoryParameter("Working directory."))
NullParameter testParameter = parser.add(
new NullParameter("Simulate file encoding.")).addAliases("-t",
- "--test");
+ "--test");
NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
NullParameter forPortableParameter = parser.add(
new NullParameter("Encode for portable player.")).addAliases("-p",
- "--portable");
+ "--portable");
StringParameters inputPatternParameter = parser
.add(new StringParameters("File input pattern."))
BitrateParameter audioBitrateParameter = parser.add(
new BitrateParameter("Audio bitrate")).addAliases("-a",
- "--audio-bitrate");
+ "--audio-bitrate");
/**
* @return {@link EncodingOptions} if commandline arguments were
/*
* 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.
+ targetFormat
+ " format.");
else {
- final AbstractConverter chosenFormat = formats.get(0);
+ final AbstractConverter chosenFormat = formats
+ .get(0);
final EncodingTask encodingTask = new EncodingTask(
- sourceFile, targetFile, chosenFormat);
+ sourceFile, targetFile, chosenFormat,
+ targetFormat);
if (chosenFormat.isTerminalMandatory())
encodingTask.setUseTerminal(true);
/*
* 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.
private boolean useTerminal;
- public EncodingTask(final File source, final File destination,
- final eu.svjatoslav.meviz.encoder.converters.AbstractConverter converter) {
+ private String targetFormat;
+
+ public EncodingTask(
+ final File source,
+ final File destination,
+ final eu.svjatoslav.meviz.encoder.converters.AbstractConverter converter,
+ String targetFormat) {
this.source = source;
target = destination;
this.converter = converter;
-
+ this.targetFormat = targetFormat;
}
/**
}
public String getCommand(final EncodingOptions encodingOptions) {
- return converter.getCommand(source, target, encodingOptions);
+ return converter.getCommand(source, target, encodingOptions,
+ targetFormat);
}
/**
/*
* 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.
public abstract class AbstractConverter {
public abstract String getCommand(File inputFile, File targetFile,
- EncodingOptions options);
+ EncodingOptions options, String targetFormat);
public abstract List<String> getSourceFileExtensions();
/*
* 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.
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
final String codecParams = "-b:a 192k";
public class AvconvVideo extends AbstractConverter {
- private void constructCodecParamsString(final EncodingOptions options,
+ private String constructCodecParamsString(final EncodingOptions options,
final int videoBitrate, final int audioBitrate,
- final StringBuffer codecParams, final String videoCodec,
- final String audioCodec) {
+ final String videoCodec, final String audioCodec) {
+
+ StringBuffer codecParams = new StringBuffer();
if (audioCodec == null)
codecParams.append("-an ");
if (options.deinterlace)
codecParams.append("-filter:v yadif ");
+
+ return codecParams.toString();
}
private int getAudioBitrateValue(final BitrateParameter.bitrate bitRate) {
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
int videoBitrate = getVideoBitrateValue(options.getVideoBitrate());
int audioBitrate = getAudioBitrateValue(options.getAudioBitrate());
String videoCodec = "libx264";
String audioCodec = "libmp3lame";
+ if (targetFormat.equals("webm")) {
+ videoCodec = "vp9";
+ audioCodec = "opus";
+ }
+
if (options.getVideoBitrate() == bitrate.COPY)
videoCodec = "copy";
codecParams.append("-s 640x480 ");
}
- constructCodecParamsString(options, videoBitrate, audioBitrate,
- codecParams, videoCodec, audioCodec);
+ codecParams.append(constructCodecParamsString(options, videoBitrate,
+ audioBitrate, videoCodec, audioCodec));
return "avconv -i \"" + inputFile.getAbsolutePath() + "\" "
+ codecParams.toString() + "\"" + targetFile.getAbsolutePath()
@Override
public List<String> getSourceFileExtensions() {
- return toList("mkv", "mts", "mp4", "avi", "mpg", "mpeg", "vob", "m4v");
+ return toList("mkv", "mts", "mp4", "avi", "mpg", "mpeg", "vob", "m4v",
+ "webm");
}
@Override
public List<String> getTargetFileExtensions() {
- return toList("mkv", "mts", "mp4", "avi", "mpg", "mpeg", "vob", "m4v");
+ return toList("mkv", "mts", "mp4", "avi", "mpg", "mpeg", "vob", "m4v",
+ "webm");
}
private int getVideoBitrateValue(final BitrateParameter.bitrate bitRate) {
/*
* 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.
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
return "convert \"" + inputFile.getAbsolutePath() + "\" \""
+ targetFile.getAbsolutePath() + "\"";
}
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
return "ffmpeg2theora \"" + inputFile.getAbsolutePath() + "\" -o \""
+ targetFile.getAbsolutePath()
+ "\" --optimize --videobitrate 3000 --width 800";
/*
* 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.
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
return "flac -8 \"" + inputFile.getAbsolutePath() + "\" -o \""
+ targetFile.getAbsolutePath() + "\"";
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
return "timidity \"" + inputFile.getAbsolutePath() + "\" -Ow -o \""
+ targetFile.getAbsolutePath() + "\"";
/*
* 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.
@Override
public String getCommand(final File inputFile, final File targetFile,
- final EncodingOptions options) {
+ final EncodingOptions options, String targetFormat) {
return "oggdec \"" + inputFile.getAbsolutePath() + "\" -o \""
+ targetFile.getAbsolutePath() + "\"";
final File targetFile = new File(targetFilePath.toString());
final EncodingTask encodingTask = new EncodingTask(sourceFile,
- targetFile, converter);
+ targetFile, converter, "mp4");
encodingPlan.scheduleTask(encodingTask);
}
}
validMetadataFiles.add(thumbnailFileName);
final File thumbnailFile = new File(
Utils.getThumbnailsDirectoryPath(directoryToIndex)
- + thumbnailFileName);
+ + thumbnailFileName);
if (!thumbnailFile.exists()) {
desiredDimension.getAwtDimension());
}
return Constants.THUMBNAILS_DIRECTORY_NAME + "/"
- + UrlParamEncoder.encode(thumbnailFileName);
+ + UrlParamEncoder.encode(thumbnailFileName);
}
public void initializeLayouts() {
metadataFile = new File(
Utils.getThumbnailsDirectoryPath(directoryToIndex)
- + Constants.METADATA_FILE_NAME);
+ + Constants.METADATA_FILE_NAME);
metadata = MetadadaHelper.initDirectoryMetadata(metadataFile);
}
public class ImageFormatError extends Exception {
- private static final long serialVersionUID = 4037233564457071385L;
+ private static final long serialVersionUID = 4037233564457071385L;
- public ImageFormatError(final String message) {
- super(message);
- }
+ public ImageFormatError(final String message) {
+ super(message);
+ }
}
public class Utils {
+ private static File lastLoadedFile;
+
+ private static BufferedImage lastLoadedBufferedImage;
+
/**
* Load image into {@link BufferedImage} and return it. Caches last loaded
* image to speed up subsequent loading attempts.
return isMevizFile;
}
- private static File lastLoadedFile;
-
- private static BufferedImage lastLoadedBufferedImage;
-
}
public class MixedLayout implements Layout {
+ public static final String encoding = "UTF-8";
+
Logger logger = Logger.getLogger(MixedLayout.class);
StringBuffer dirHtml = new StringBuffer();
List<String> path;
- public static final String encoding = "UTF-8";
-
private AbstractIndexer indexer;
private IndexingContext indexingContext;
"Error generating thumbnails for image file: "
+ e.toString()
+ ", thumbnail generation skipped, enlisting as ordinary file instead.",
- e);
+ e);
enlistFile(picture, parentDirectoryMetadata);
}
}
@Override
public void enlistOgv(final AbstractFile abstractFile,
final DirectoryMetadata parentDirectoryMetadata)
- throws UnsupportedEncodingException {
+ throws UnsupportedEncodingException {
final GeneralFile file = (GeneralFile) abstractFile;
// watchable video
filesHtml
- .append("<video preload=\"metadata\" controls=\"controls\" tabindex=\"0\">\n");
+ .append("<video preload=\"metadata\" controls=\"controls\" tabindex=\"0\">\n");
filesHtml
- .append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
- + indexingContext.getGlobalUrl()
- + UrlParamEncoder.encode(indexingContext.getLocalUrl()
- + "/" + file.fileName) + "\">\n");
+ .append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
+ + indexingContext.getGlobalUrl()
+ + UrlParamEncoder.encode(indexingContext.getLocalUrl()
+ + "/" + file.fileName) + "\">\n");
filesHtml.append("</source>\n");
filesHtml.append("</video>\n");
filesHtml.append("<br/>\n");
// video title
filesHtml
- .append("Video: <b>"
- + FilePathParser
- .getFileNameWithoutExtension(file.fileName)
- + "<b/> ");
+ .append("Video: <b>"
+ + FilePathParser
+ .getFileNameWithoutExtension(file.fileName)
+ + "<b/> ");
// video download link
filesHtml.append("<a href=\""
public class MevizSpecialFile extends AbstractFile {
- private String fileContent;
-
private static final long serialVersionUID = -8749190459653455640L;
+ private String fileContent;
+
public MevizSpecialFile(final File parentDirectory, final String fileName)
throws Exception {
super(parentDirectory, fileName);
public class Picture extends AbstractFile {
+ private static final long serialVersionUID = -4156533490858298387L;
+
private static void ensureNonzeroImageArea(final java.awt.Dimension result) {
if (result.width < 1)
result.width = 1;
final Image newImage = Toolkit.getDefaultToolkit().createImage(prod);
return new ImageIcon(newImage).getImage();
- }
-
- private static final long serialVersionUID = -4156533490858298387L;;
+ };
/**
* Picture dimensions.
public class RenamingOptions {
- public ArrayList<String> inputPatterns = new ArrayList<String>();
+ public ArrayList<String> inputPatterns = new ArrayList<String>();
- public boolean recursive = false;
+ public boolean recursive = false;
- public boolean testOnly = false;
+ public boolean testOnly = false;
- public String outputPattern;
+ public String outputPattern;
- public File targetDirectory;
+ public File targetDirectory;
}
StringParameter replaceWithPattern = parser.add(
new StringParameter("String to place instead")).addAliases("-p",
- "--replace-pattern");
+ "--replace-pattern");
DirectoryParameter directoryParameter = parser
.add(new DirectoryParameter("Working directory."))
public String replaceWithPattern;
-
public boolean recursive = false;
public File targetDirectory;
StringParameters inputPatternParameter = parser.add(
new StringParameters("File input pattern.")).addAliases("-i",
- "--input-pattern");
+ "--input-pattern");
DirectoryParameter workingDirectoryParameter = parser.add(
new DirectoryParameter("Working directory.")).addAliases("-w",