/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012 -- 2017-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
-*/
+ * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
package eu.svjatoslav.meviz.encoder.converters;
--- /dev/null
+/*
+ * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+
+package eu.svjatoslav.meviz.encoder.converters;
+
+import eu.svjatoslav.meviz.encoder.EncodingOptions;
+
+import java.io.File;
+import java.util.List;
+
+public class Cwebp extends AbstractConverter {
+
+ @Override
+ public String getCommand(final File inputFile, final File targetFile,
+ final EncodingOptions options, String targetFormat) {
+
+ String quality;
+
+ switch (options.getVideoBitrate()) {
+ case LOW:
+ quality = " -q 10 ";
+ break;
+ case MEDIUM:
+ quality = " -q 50 ";
+ break;
+ case HIGH:
+ quality = " -q 80 ";
+ break;
+ case COPY:
+ case LOSSLESS:
+ default:
+ quality = " -lossless ";
+ }
+
+ return "cwebp \"" + inputFile.getAbsolutePath() + "\"" + quality + " -o \""
+ + targetFile.getAbsolutePath() + "\"";
+ }
+
+ @Override
+ public List<String> getSourceFileExtensions() {
+ return toList("tif", "tiff", "png", "jpg", "jpeg", "bmp", "gif");
+ }
+
+ @Override
+ public List<String> getTargetFileExtensions() {
+ return toList("webp");
+ }
+
+ @Override
+ public boolean isTerminalMandatory() {
+ return false;
+ }
+
+}