Adds a converter to embed subtitles
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
This commit is contained in:
@ -19,6 +19,7 @@ import java.util.List;
|
||||
public final class FFMpegHelper {
|
||||
|
||||
private static final String PROBE_SPLIT_CHARACTER = "øæåÆØå";
|
||||
private static String[] subtitleFormats = null;
|
||||
|
||||
private FFMpegHelper() {
|
||||
|
||||
@ -305,7 +306,9 @@ public final class FFMpegHelper {
|
||||
throws IOException {
|
||||
List<StreamObject> parsedStreams = new ArrayList<>();
|
||||
//Find all files in the same directory with external subtitle formats
|
||||
String[] subtitleFormats = FileUtil.readFileLines("subtitle_formats.txt");
|
||||
if (subtitleFormats == null) {
|
||||
subtitleFormats = FileUtil.readFileLines("subtitle_formats.txt");
|
||||
}
|
||||
File[] subtitleFiles = FileUtil.listFilesRecursive(directory, subtitleFormats, 1);
|
||||
|
||||
//Return early if no files were found
|
||||
@ -315,9 +318,11 @@ public final class FFMpegHelper {
|
||||
|
||||
String fileTitle = FileUtil.stripExtension(convertingFile);
|
||||
List<File> subtitleFilesList = new ArrayList<>(Arrays.asList(subtitleFiles));
|
||||
|
||||
//Finds the files which are subtitles probably belonging to the file
|
||||
subtitleFilesList = ListUtil.getMatching(subtitleFilesList,
|
||||
(subtitleFile) -> subtitleFile.getName().contains(fileTitle));
|
||||
|
||||
for (File subtitleFile : subtitleFilesList) {
|
||||
//Probe the files and add them to the result list
|
||||
String[] streams = probeForStreams(ffprobePath, subtitleFile);
|
||||
|
Reference in New Issue
Block a user