diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java index 3e5ed87..3a1555c 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/AnimeConverter.java @@ -113,7 +113,7 @@ public class AnimeConverter extends Converter { command.add("-map"); command.add("0:" + videoStream.getAbsoluteIndex()); command.add("-vf"); - String safeFileName = fileName.replace("'", "\\\\\\'").replace("]", "\\]").replace("[", "\\["); + String safeFileName = escapeSpecialCharactersInFileName(fileName); String subtitleCommand = String.format("subtitles=\"%s\"", safeFileName); command.add(subtitleCommand); } else { diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/Converter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/Converter.java index 16f8fa2..455c126 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/Converter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/Converter.java @@ -423,6 +423,14 @@ public abstract class Converter { } return new SubtitleStream(codecName, absoluteIndex, relativeIndex, language, title); } + + static String escapeSpecialCharactersInFileName(String fileName) { + return fileName.replace("'", "\\\\\\'") + .replace(",", "\\\\\\,") + .replace(";", "\\\\\\;") + .replace("]", "\\]") + .replace("[", "\\["); + } static void print(String input) throws IOException { if (!input.equals("")) {