diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java index 388550d..b286595 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java @@ -57,8 +57,10 @@ public class AnimeConverter extends Converter { } String newPath = fileCollisionPrevention(folder.getAbsolutePath() + File.separator + stripExtension(file) + ".mp4", "mp4"); + printl(); printl("Preparing to start process..."); - String[] command = builderCommand(ffmpegPath, file.getName(), streams, newPath); + printl("Converting " + file); + String[] command = builderCommand(ffmpegPath, file.getName(), streams, newPath, file); ProcessBuilder processBuilder = new ProcessBuilder(command); convertProcess(processBuilder, folder); } @@ -71,7 +73,8 @@ public class AnimeConverter extends Converter { * @param outFile
The output file.
* @returnA list of commands
*/ - private String[] builderCommand(String executable, String fileName, ListThe subtitle stream to be used.
* @param videoStreamThe video stream to be used.
* @param fileNameThe name of the file which is converted.
+ * @param fileThe file to convert.
*/ private void addSubtitles(ListThe text to print.
* @throws IOExceptionIf a write is not possible.
*/ - static void print(String input) throws IOException { + private static void print(String input) throws IOException { if (!input.equals("")) { writer.write(input); writer.flush(); @@ -479,4 +479,37 @@ public abstract class Converter { writer.newLine(); writer.flush(); } + + /** + * Checks whether there exists an external image subtitle with the same filename as the file + * @param directoryThe directory containing the file.
+ * @param fileThe file to be converted.
+ * @returnThe extension of the subtitle or empty if no subtitle was found.
+ */ + String hasExternalImageSubtitle(String directory, String file) { + String path = stripExtension(file); + for (String subtitleExtension : new String[] {".idx", ".sub"}) { + if (new File(directory + File.separator + path + subtitleExtension).exists()) { + return path + subtitleExtension; + } + } + return ""; + } + + /** + * Checks whether there exists an external subtitle with the same filename as the file + * @param directoryThe directory containing the file.
+ * @param fileThe file to be converted.
+ * @returnThe extension of the subtitle or empty if no subtitle was found.
+ */ + String hasExternalSubtitle(String directory, String file) { + String path = stripExtension(file); + for (String subtitleExtension : new String[] {".srt", ".ass"}) { + System.out.println(directory + File.separator + path + subtitleExtension); + if (new File(directory + File.separator + path + subtitleExtension).exists()) { + return path + subtitleExtension; + } + } + return ""; + } } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/VideoConverter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/VideoConverter.java index a8a3874..4f8168c 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/VideoConverter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/VideoConverter.java @@ -95,10 +95,10 @@ public class VideoConverter extends Converter { String externalImageSubtitle = hasExternalImageSubtitle(folder.getAbsolutePath(), fileName); if (!externalSubtitle.equals("")) { command.add("-vf"); - command.add("subtitles=" + stripExtension(fileName) + externalSubtitle); + command.add("subtitles=" + externalSubtitle); } else if (!externalImageSubtitle.equals("")) { command.add("-i"); - command.add(stripExtension(fileName) + externalImageSubtitle); + command.add(externalImageSubtitle); if (this.DEBUG) { addDebug(command, 50, 120); } @@ -122,38 +122,6 @@ public class VideoConverter extends Converter { command.add("pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR"); } - /** - * Checks whether there exists an external image subtitle with the same filename as the file - * @param directoryThe directory containing the file.
- * @param fileThe file to be converted.
- * @returnThe extension of the subtitle or empty if no subtitle was found.
- */ - private String hasExternalImageSubtitle(String directory, String file) { - String path = stripExtension(file); - for (String subtitleExtension : new String[] {".idx", ".sub"}) { - if (new File(directory + File.separator + path + subtitleExtension).exists()) { - return subtitleExtension; - } - } - return ""; - } - - /** - * Checks whether there exists an external subtitle with the same filename as the file - * @param directoryThe directory containing the file.
- * @param fileThe file to be converted.
- * @returnThe extension of the subtitle or empty if no subtitle was found.
- */ - private String hasExternalSubtitle(String directory, String file) { - String path = stripExtension(file); - for (String subtitleExtension : new String[] {".srt", ".ass"}) { - if (new File(directory + File.separator + path + subtitleExtension).exists()) { - return subtitleExtension; - } - } - return ""; - } - @Override public String[] getValidFormats() { return VIDEO_FORMATS;