Fixes subtitle mapping for video with only external 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:
@ -285,7 +285,7 @@ public final class FFMpegHelper {
|
||||
} else if (stream.contains("codec_type=audio")) {
|
||||
parsedStreams.add(parseAudioStream(streamParts, relativeAudioIndex++));
|
||||
} else if (stream.contains("codec_type=subtitle")) {
|
||||
parsedStreams.add(parseSubtitleStream(streamParts, relativeSubtitleIndex++, file.getName()));
|
||||
parsedStreams.add(parseSubtitleStream(streamParts, relativeSubtitleIndex++, file.getName(), true));
|
||||
}
|
||||
}
|
||||
List<StreamObject> externalSubtitles = getExternalSubtitles(ffprobePath, file.getParentFile(), file.getName());
|
||||
@ -323,7 +323,7 @@ public final class FFMpegHelper {
|
||||
String[] streams = probeForStreams(ffprobePath, subtitleFile);
|
||||
for (String stream : streams) {
|
||||
String[] streamParts = stream.split(PROBE_SPLIT_CHARACTER);
|
||||
parsedStreams.add(parseSubtitleStream(streamParts, 0, subtitleFile.getName()));
|
||||
parsedStreams.add(parseSubtitleStream(streamParts, 0, subtitleFile.getName(), false));
|
||||
}
|
||||
}
|
||||
return parsedStreams;
|
||||
@ -405,14 +405,15 @@ public final class FFMpegHelper {
|
||||
/**
|
||||
* Parses a list of subtitle stream parameters to a subtitle stream object
|
||||
*
|
||||
* @param streamParts <p>A list of parameters belonging to a subtitle stream.</p>
|
||||
* @param relativeIndex <p>The relative index of the subtitle.</p>
|
||||
* @param file <p>The file currently being converted.</p>
|
||||
* @param streamParts <p>A list of parameters belonging to a subtitle stream.</p>
|
||||
* @param relativeIndex <p>The relative index of the subtitle.</p>
|
||||
* @param file <p>The file currently being converted.</p>
|
||||
* @param isInternalStream <p>Whether the subtitle stream is in the main video file</p>
|
||||
* @return <p>A SubtitleStream object.</p>
|
||||
* @throws NumberFormatException <p>If codec index contains a non-numeric value.</p>
|
||||
*/
|
||||
private static SubtitleStream parseSubtitleStream(String[] streamParts, int relativeIndex, String file)
|
||||
throws NumberFormatException {
|
||||
private static SubtitleStream parseSubtitleStream(String[] streamParts, int relativeIndex, String file,
|
||||
boolean isInternalStream) throws NumberFormatException {
|
||||
String codecName = null;
|
||||
int absoluteIndex = -1;
|
||||
String language = null;
|
||||
@ -428,7 +429,7 @@ public final class FFMpegHelper {
|
||||
title = streamPart.replace("TAG:title=", "");
|
||||
}
|
||||
}
|
||||
return new SubtitleStream(codecName, absoluteIndex, relativeIndex, language, title, file);
|
||||
return new SubtitleStream(codecName, absoluteIndex, relativeIndex, language, title, file, isInternalStream);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user