Changes main package name and fixes files with weird names throwing errors
All checks were successful
KnarCraft/FFmpegConvert/master This commit looks good

Fixes conversion of files with a single quote or square brackets in the filename
Moves all files into the net.knarcraft.ffmpegconverter package
This commit is contained in:
2020-02-21 17:23:00 +01:00
parent c80193281d
commit 4e1cebd95d
13 changed files with 39 additions and 40 deletions

View File

@@ -0,0 +1,132 @@
package net.knarcraft.ffmpegconverter.converter;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class AnimeConverter extends Converter {
private String[] audioLang;
private String[] subtitleLang;
private boolean toStereo;
private boolean preventSignsAndSongs;
private boolean debug = false;
/**
* @param ffprobePath Path/command to ffprobe
* @param ffmpegPath Path/command to ffmpeg
* @param audioLang List of wanted audio languages in descending order
* @param subtitleLang List of wanted subtitle languages in descending order
* @param toStereo Convert video with several audio channels to stereo
* @param preventSignsAndSongs Prevent subtitles only converting signs and songs (not speech)
*/
public AnimeConverter(String ffprobePath, String ffmpegPath, String[] audioLang, String[] subtitleLang, boolean toStereo, boolean preventSignsAndSongs) {
this.ffprobePath = ffprobePath;
this.ffmpegPath = ffmpegPath;
this.audioLang = audioLang;
this.subtitleLang = subtitleLang;
this.toStereo = toStereo;
this.preventSignsAndSongs = preventSignsAndSongs;
}
public void convert(File file) throws IOException {
processFile(file.getParentFile(), file);
}
/**
* Reads streams from a file, and converts it to an mp4.
*
* @param folder The folder of the file to process
* @param file The file to process
* @throws IOException If the BufferedReader fails
*/
private void processFile(File folder, File file) throws IOException {
List<StreamObject> streams = probeFile(ffprobePath, file);
if (streams.isEmpty()) {
throw new IllegalArgumentException("The file has no valid streams. Please make sure the file exists and is not corrupt.");
}
String newPath = fileCollisionPrevention(folder.getAbsolutePath() + File.separator + stripExtension(file) + ".mp4", "mp4");
printl("Preparing to start process...");
String[] command = builderCommand(ffmpegPath, file.getName(), streams, newPath);
ProcessBuilder processBuilder = new ProcessBuilder(command);
convertProcess(processBuilder, folder);
}
/**
* Generates a command for a ProcessBuilder.
*
* @param executable The executable file for ffmpeg
* @param fileName The input file
* @param streams A list of ffprobe streams
* @param outFile The output file
* @return A list of commands
*/
private String[] builderCommand(String executable, String fileName, List<StreamObject> streams, String outFile) {
List<String> command = ffmpegWebVideo(executable, fileName);
if (this.debug) {
addDebug(command, 50, 120);
}
List<AudioStream> audioStreams = filterStreamsByType(streams, "audio");
List<VideoStream> videoStreams = filterStreamsByType(streams, "video");
List<SubtitleStream> subtitleStreams = filterStreamsByType(streams, "subtitle");
audioStreams = filterAudioStreams(audioStreams, audioLang);
subtitleStreams = filterSubtitleStreams(subtitleStreams, subtitleLang, preventSignsAndSongs);
VideoStream videoStream = null;
AudioStream audioStream = null;
SubtitleStream subtitleStream = null;
if (videoStreams.size() > 0) {
videoStream = videoStreams.get(0);
}
if (audioStreams.size() > 0) {
audioStream = audioStreams.get(0);
}
if (subtitleStreams.size() > 0) {
subtitleStream = subtitleStreams.get(0);
}
if (videoStream == null) {
throw new IllegalArgumentException("The file does not have any valid video streams.");
}
if (audioStream != null) {
command.add("-map");
command.add("0:" + audioStream.getAbsoluteIndex());
if (toStereo && audioStream.getChannels() > 2) {
command.add("-af");
command.add("pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR");
}
}
if (subtitleStream != null && subtitleStream.getIsImageSubtitle()) {
command.add("-filter_complex");
command.add("[0:v:" + videoStream.getAbsoluteIndex() + "][0:" + subtitleStream.getAbsoluteIndex() + "]overlay");
} else if (subtitleStream != null) {
command.add("-map");
command.add("0:" + videoStream.getAbsoluteIndex());
command.add("-vf");
String safeFileName = fileName.replace("'", "\\\\\\'").replace("]", "\\]").replace("[", "\\[");
String subtitleCommand = String.format("subtitles=\"%s\"", safeFileName);
command.add(subtitleCommand);
} else {
command.add("-map");
command.add("0:" + videoStream.getAbsoluteIndex());
}
command.add(outFile);
return command.toArray(new String[0]);
}
@Override
public String[] getValidFormats() {
return VIDEO_FORMATS;
}
}

View File

@@ -0,0 +1,68 @@
package net.knarcraft.ffmpegconverter.converter;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class AudioConverter extends Converter {
private String newExt;
public AudioConverter(String ffprobePath, String ffmpegPath, String newExt) {
this.ffprobePath = ffprobePath;
this.ffmpegPath = ffmpegPath;
this.newExt = newExt;
}
/**
* Reads streams from a file, and converts it to an mp4.
*
* @param folder The folder of the file to process
* @param file The file to process
* @throws IOException If the BufferedReader fails
*/
private void processFile(File folder, File file, String newExt) throws IOException {
List<StreamObject> streams = probeFile(ffprobePath, file);
if (streams.size() == 0) {
throw new IllegalArgumentException("The file has no streams");
}
String newPath = stripExtension(file) + "." + newExt;
convertProcess(new ProcessBuilder(builderCommand(ffmpegPath, file.getName(), streams, newPath)), folder);
}
/**
* Generates a command for a ProcessBuilder.
*
* @param executable The executable file for ffmpeg
* @param fileName The input file
* @param streams A list of ffprobe streams
* @param outFile The output file
* @return A list of commands
*/
private String[] builderCommand(String executable, String fileName, List<StreamObject> streams, String outFile) {
List<String> command = generalFile(executable, fileName);
List<AudioStream> audioStreams = filterStreamsByType(streams, "audio");
AudioStream audioStream = null;
if (audioStreams.size() > 0) {
audioStream = audioStreams.get(0);
}
if (audioStreams.size() > 0) {
command.add("-map");
command.add("0:" + audioStream.getAbsoluteIndex());
}
command.add(outFile);
return command.toArray(new String[0]);
}
@Override
public String[] getValidFormats() {
return AUDIO_FORMATS;
}
@Override
public void convert(File file) throws IOException {
processFile(file.getParentFile(), file, newExt);
}
}

View File

@@ -0,0 +1,441 @@
package net.knarcraft.ffmpegconverter.converter;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;
/**
* Implements all methods which can be usefull for any implementation of a converter.
*/
public abstract class Converter {
String ffprobePath;
String ffmpegPath;
private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
private static final String PROBE_SPLIT_CHARACTER = "øæåÆØå";
public abstract String[] getValidFormats();
public abstract void convert(File file) throws IOException;
final String[] AUDIO_FORMATS = new String[] {".3gp", ".aa", ".aac", ".aax", ".act", ".aiff", ".amr", ".ape", ".au",
".awb", ".dct", ".dss", ".dvf", ".flac", ".gsm", ".iklax", ".ivs", ".m4a", ".m4b", ".m4p", ".mmf", ".mp3",
".mpc", ".msv", ".ogg", ".oga", ".mogg", ".opus", ".ra", ".rm", ".raw", ".sln", ".tta", ".vox", ".wav",
".wma", ".wv", ".webm", ".8svx"};
final String[] VIDEO_FORMATS = new String[] {".avi", ".mpg", ".mpeg", ".mkv", ".wmv", ".flv", ".webm", ".3gp",
".rmvb", ".3gpp", ".mts", ".m4v", ".mov", ".rm", ".asf", ".mp4", ".vob", ".ogv", ".drc", ".qt", ".yuv",
".asm", ".m4p", ".mp2", ".mpe", ".mpv", ".m2v", ".svi", ".3g2", ".roq", ".nsv"};
/**
* Gets streams from a file
* @param ffprobePath The path/command to ffprobe
* @param file The file to probe
* @return A list of StreamObjects
* @throws IOException If the process can't be read
*/
static List<StreamObject> probeFile(String ffprobePath, File file) throws IOException {
ProcessBuilder builderProbe = new ProcessBuilder(
ffprobePath,
"-v",
"error",
"-show_entries",
"stream_tags=language,title:stream=index,codec_name,codec_type,channels",
file.toString()
);
print("Probe command: ");
printl(builderProbe.command().toString());
builderProbe.redirectErrorStream(true);
Process processProbe = builderProbe.start();
BufferedReader readerProbe = new BufferedReader(new InputStreamReader(processProbe.getInputStream()));
StringBuilder output = new StringBuilder();
while (processProbe.isAlive()) {
String read = read(readerProbe, PROBE_SPLIT_CHARACTER);
if (!read.equals("")) {
print(read);
output.append(read);
}
}
return parseStreams(stringBetween(output.toString(), "[STREAM]", "[/STREAM]"));
}
static String fileCollisionPrevention(String targetPath, String extension) {
File file = new File(targetPath);
int i = 1;
while (file.exists()) {
file = new File(stripExtension(file) + "(" + i + ")" + "." + extension);
}
return file.toString();
}
/**
* Starts and prints output of a process
* @param process The process to run
* @param folder The folder the process should run in
* @throws IOException If the process can't be read
*/
static void convertProcess(ProcessBuilder process, File folder) throws IOException {
print("Command to be run: ");
printl(process.command().toString());
process.directory(folder);
process.redirectErrorStream(true);
Process processConvert = process.start();
BufferedReader readerConvert = new BufferedReader(new InputStreamReader(processConvert.getInputStream()));
while (processConvert.isAlive()) {
String read = read(readerConvert, "\n");
if (!read.equals("")) {
printl(read);
}
}
printl("FFMPEG is finished.");
}
/**
* Reads from a process reader.
*
* @param reader The reader of a process
* @return The output from the read
* @throws IOException On reader failure
*/
private static String read(BufferedReader reader, String spacer) throws IOException {
String line;
StringBuilder text = new StringBuilder();
while (reader.ready() && (line = reader.readLine()) != null && !line.equals("") && !line.equals("\n")) {
text.append(line).append(spacer);
}
return text.toString().trim();
}
/**
* @return A base list of ffmpeg commands for converting a video for web
*/
static List<String> ffmpegWebVideo(String executable, String fileName) {
List<String> command = generalFile(executable, fileName);
command.add("-vcodec");
command.add("h264");
command.add("-pix_fmt");
command.add("yuv420p");
command.add("-ar");
command.add("48000");
command.add("-movflags");
command.add("+faststart");
return command;
}
/**
* @return A base list of ffmpeg commands for converting a file
*/
static List<String> generalFile(String executable, String fileName) {
List<String> command = new ArrayList<>();
command.add(executable);
command.add("-nostdin");
command.add("-i");
command.add(fileName);
return command;
}
/**
* Adds debugging parameters for only converting parts of a file
* @param command The list containing the command to run
* @param start The offset before converting
* @param length The offset for stopping the conversion
*/
static void addDebug(List<String> command, int start, int length) {
command.add("-ss");
command.add("" + start);
command.add("-t");
command.add("" + length);
}
/**
* Lists all indexes fulfilling a predicate.
*
* @param list A list of ffprobe indexes
* @return An integer list containing just the wanted indexes
*/
private static List<Integer> listIndexes(String[] list, Predicate<String> p) {
List<Integer> indexes = new ArrayList<>();
for (String str : list) {
if (p.test(str)) {
indexes.add(Integer.parseInt(stringBetweenSingle(str, "index=", PROBE_SPLIT_CHARACTER)));
}
}
return indexes;
}
/**
* Tests a predicate on a list
* @param list A list
* @param p A predicate
* @param <T> Any type
* @return True if the list have an element for which the predicate is true
*/
private static <T> boolean testPredicate(T[] list, Predicate<T> p) {
for (T o : list) {
if (p.test(o)) {
return true;
}
}
return false;
}
/**
* Finds all substrings between two substrings in a string.
*
* @param string The string containing the substrings
* @param start The substring before the wanted substring
* @param end The substring after the wanted substring
* @return A list of all occurrences of the substring
*/
private static String[] stringBetween(String string, String start, String end) {
int startPos = string.indexOf(start) + start.length();
if (!string.contains(start) || string.indexOf(end, startPos) < startPos) {
return new String[]{};
}
int endPos = string.indexOf(end, startPos);
String outString = string.substring(startPos, endPos).trim();
String nextString = string.substring(endPos + end.length());
return concatenate(new String[]{outString}, stringBetween(nextString, start, end));
}
/**
* Finds a substring between two substrings in a string.
*
* @param string The string containing the substrings
* @param start The substring before the wanted substring
* @param end The substring after the wanted substring
* @return The wanted substring.
*/
private static String stringBetweenSingle(String string, String start, String end) {
int startPos = string.indexOf(start) + start.length();
if (!string.contains(start) || string.indexOf(end, startPos) < startPos) {
return "";
}
return string.substring(startPos, string.indexOf(end, startPos));
}
/**
* Gets filename without extension from File object
* @param file A file object
* @return A filename
*/
static String stripExtension(File file) {
return file.getName().substring(0, file.getName().lastIndexOf('.'));
}
/**
* Removes the extension from a file name
* @param file A filename
* @return A filename without its extension
*/
static String stripExtension(String file) {
return file.substring(0, file.lastIndexOf('.'));
}
/**
* Combines two arrays to one
*
* @param a The first array
* @param b The second array
* @param <T> Any type
* @return A new array containing all elements from the two arrays
*/
public static <T> T[] concatenate(T[] a, T[] b) {
int aLen = a.length;
int bLen = b.length;
@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
/**
* Filters parsed streams into one of the stream types
* @param streams A list of stream objects
* @param codecType The codec type of the streams to select
* @param <G> The correct object type for the streams with the selected codec type
* @return A potentially shorter list of streams
*/
static <G extends StreamObject> List<G> filterStreamsByType(List<StreamObject> streams, String codecType) {
Iterator<StreamObject> i = streams.iterator();
List<G> newStreams = new ArrayList<>();
while (i.hasNext()) {
StreamObject next = i.next();
if (next.getCodecType().equals(codecType)) {
newStreams.add((G) next);
}
}
return newStreams;
}
/**
* Filters and sorts audio streams according to chosen languages
* @param audioStreams A list of audio streams
* @param audioLanguages A list of languages
* @return A list containing just audio tracks of chosen languages, sorted in order of languages
*/
static List<AudioStream> filterAudioStreams(List<AudioStream> audioStreams, String[] audioLanguages) {
List<AudioStream> filtered = new ArrayList<>();
for (String language : audioLanguages) {
for (AudioStream stream : audioStreams) {
if ((stream.getLanguage() != null && stream.getLanguage().equals(language)) || language.equals("*")) {
filtered.add(stream);
}
}
//Tries to reduce execution time from n^2
audioStreams.removeAll(filtered);
}
return filtered;
}
/**
* Filters and sorts subtitle streams according to chosen languages
* @param subtitleStreams A list of subtitle streams
* @param subtitleLanguages A list of languages
* @param preventSignsAndSongs Whether partial subtitles should be avoided
* @return A list containing just subtitles of chosen languages, sorted in order of languages
*/
static List<SubtitleStream> filterSubtitleStreams(List<SubtitleStream> subtitleStreams, String[] subtitleLanguages,
boolean preventSignsAndSongs) {
List<SubtitleStream> filtered = new ArrayList<>();
//Go through languages. Select all subtitles of the language
for (String language : subtitleLanguages) {
for (SubtitleStream stream : subtitleStreams) {
String streamLanguage = stream.getLanguage();
if (((streamLanguage != null && streamLanguage.equals(language)) || language.equals("*")) &&
(!preventSignsAndSongs || stream.getIsFullSubtitle())) {
filtered.add(stream);
}
}
//Tries to reduce execution time from n^2
subtitleStreams.removeAll(filtered);
}
return filtered;
}
/**
* Takes a list of all streams and parses each stream into one of three objects
* @param streams A list of all streams for the current file
* @return A list of StreamObjects
*/
private static List<StreamObject> parseStreams(String[] streams) {
List<StreamObject> parsedStreams = new ArrayList<>();
int relativeAudioIndex = 0;
int relativeVideoIndex = 0;
int relativeSubtitleIndex = 0;
for (String stream : streams) {
String[] streamParts = stream.split(PROBE_SPLIT_CHARACTER);
if (stream.contains("codec_type=video")) {
parsedStreams.add(parseVideoStream(streamParts, relativeVideoIndex++));
} else if (stream.contains("codec_type=audio")) {
parsedStreams.add(parseAudioStream(streamParts, relativeAudioIndex++));
} else if (stream.contains("codec_type=subtitle")) {
parsedStreams.add(parseSubtitleStream(streamParts, relativeSubtitleIndex++));
}
}
return parsedStreams;
}
/**
* Parses a list of video stream parameters to a video stream object
* @param streamParts A list of parameters belonging to an video stream
* @param relativeIndex The relative index of the video stream
* @return A SubtitleStream object
* @throws NumberFormatException If codec index contains a non-numeric value
*/
private static VideoStream parseVideoStream(String[] streamParts, int relativeIndex) throws NumberFormatException {
String codec = null;
int absoluteIndex = -1;
for (String streamPart : streamParts) {
if (streamPart.contains("codec_name=")) {
codec = streamPart.replace("codec_name=", "");
} else if (streamPart.contains("index=")) {
absoluteIndex = Integer.parseInt(streamPart.replace("index=", ""));
}
}
return new VideoStream(codec, absoluteIndex, relativeIndex);
}
/**
* Parses a list of audio stream parameters to an audio stream object
* @param streamParts A list of parameters belonging to an audio stream
* @param relativeIndex The relative index of the audio stream
* @return A SubtitleStream object
* @throws NumberFormatException If codec index contains a non-numeric value
*/
private static AudioStream parseAudioStream(String[] streamParts, int relativeIndex) throws NumberFormatException {
String codec = null;
int absoluteIndex = -1;
String language = null;
int channels = 0;
String title = "";
for (String streamPart : streamParts) {
if (streamPart.contains("codec_name=")) {
codec = streamPart.replace("codec_name=", "");
} else if (streamPart.contains("index=")) {
absoluteIndex = Integer.parseInt(streamPart.replace("index=", ""));
} else if (streamPart.contains("TAG:language=")) {
language = streamPart.replace("TAG:language=", "");
} else if (streamPart.contains("channels=")) {
channels = Integer.parseInt(streamPart.replace("channels=", ""));
} else if (streamPart.contains("TAG:title=")) {
title = streamPart.replace("TAG:title=", "");
}
}
return new AudioStream(codec, absoluteIndex, relativeIndex, language, title, channels);
}
/**
* Parses a list of subtitle stream parameters to a subtitle stream object
* @param streamParts A list of parameters belonging to a subtitle stream
* @param relativeIndex The relative index of the subtitle
* @return A SubtitleStream object
* @throws NumberFormatException If codec index contains a non-numeric value
*/
private static SubtitleStream parseSubtitleStream(String[] streamParts, int relativeIndex) throws NumberFormatException {
String codecName = null;
int absoluteIndex = -1;
String language = null;
String title = "";
for (String streamPart : streamParts) {
if (streamPart.contains("codec_name=")) {
codecName = streamPart.replace("codec_name=", "");
} else if (streamPart.contains("index=")) {
absoluteIndex = Integer.parseInt(streamPart.replace("index=", ""));
} else if (streamPart.contains("TAG:language=")) {
language = streamPart.replace("TAG:language=", "");
} else if (streamPart.contains("TAG:title=")) {
title = streamPart.replace("TAG:title=", "");
}
}
return new SubtitleStream(codecName, absoluteIndex, relativeIndex, language, title);
}
static void print(String input) throws IOException {
if (!input.equals("")) {
writer.write(input);
writer.flush();
}
}
static void printl(String input) throws IOException {
if (!input.equals("")) {
writer.write(input);
}
writer.newLine();
writer.flush();
}
}

View File

@@ -0,0 +1,129 @@
package net.knarcraft.ffmpegconverter.converter;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class VideoConverter extends Converter {
private String newExt;
private boolean debug = false;
public VideoConverter(String ffprobePath, String ffmpegPath, String newExt) {
this.ffprobePath = ffprobePath;
this.ffmpegPath = ffmpegPath;
this.newExt = newExt;
}
/**
* Reads streams from a file, and converts it to an mp4.
*
* @param folder The folder of the file to process
* @param file The file to process
* @throws IOException If the BufferedReader fails
*/
private void processFile(File folder, File file, String newExt) throws IOException {
List<StreamObject> streams = probeFile(ffprobePath, file);
if (streams.size() == 0) {
throw new IllegalArgumentException("The file has no streams");
}
String newPath = fileCollisionPrevention(folder.getAbsolutePath() + File.separator + stripExtension(file) + "." + newExt, newExt);
convertProcess(new ProcessBuilder(builderCommand(ffmpegPath, file.getName(), streams, newPath, folder)), folder);
}
/**
* Generates a command for a ProcessBuilder.
*
* @param executable The executable file for ffmpeg
* @param fileName The input file
* @param streams A list of ffprobe streams
* @param outFile The output file
* @return A list of commands
*/
private String[] builderCommand(String executable, String fileName, List<StreamObject> streams, String outFile, File folder) {
List<String> command = generalFile(executable, fileName);
if (this.debug) {
addDebug(command, 50, 120);
}
List<AudioStream> audioStreams = filterStreamsByType(streams, "audio");
List<VideoStream> videoStreams = filterStreamsByType(streams, "video");
VideoStream videoStream = null;
AudioStream audioStream = null;
if (videoStreams.size() > 0) {
videoStream = videoStreams.get(0);
}
if (audioStreams.size() > 0) {
audioStream = audioStreams.get(0);
}
String ext = hasExternalSubtitle(folder.getAbsolutePath(), fileName);
String ext2 = hasExternalImageSubtitle(folder.getAbsolutePath(), fileName);
if (!ext.equals("")) {
command.add("-vf");
command.add("subtitles=" + stripExtension(fileName) + ext);
} else if (!ext2.equals("")) {
command.add("-i");
command.add(stripExtension(fileName) + ext2);
if (this.debug) {
addDebug(command, 50, 120);
}
//TODO: Scale subtitles to video
command.add("-filter_complex");
command.add("[1:s]scale=width=1920:height=800,crop=w=1920:h=800:x=0:y=out_h[sub];[" + videoStream + ":v][sub]overlay");
command.add("-profile:v");
command.add("baseline");
}
if (ext2.equals("") || !ext.equals("")) {
if (videoStreams.size() > 0) {
command.add("-map");
command.add("0:" + videoStream);
}
if (audioStreams.size() > 0) {
command.add("-map");
command.add("0:" + audioStream);
}
}
command.add("-af");
command.add("pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR");
command.add(outFile);
return command.toArray(new String[0]);
}
private String hasExternalImageSubtitle(String directory, String file) {
String path = stripExtension(file);
for (String s : new String[] {".idx", ".sub"}) {
if (new File(directory + File.separator + path + s).exists()) {
return s;
}
}
return "";
}
private String hasExternalSubtitle(String directory, String file) {
String path = stripExtension(file);
for (String s : new String[] {".srt", ".ass"}) {
if (new File(directory + File.separator + path + s).exists()) {
return s;
}
}
return "";
}
@Override
public String[] getValidFormats() {
return VIDEO_FORMATS;
}
@Override
public void convert(File file) throws IOException {
processFile(file.getParentFile(), file, newExt);
}
}