Fixes subtitle mapping for video with only external subtitles
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
2023-08-12 22:14:46 +02:00
parent 5d94cabca0
commit 56f5e31934
3 changed files with 45 additions and 16 deletions

View File

@ -56,7 +56,7 @@ public class MkvH264Converter extends AbstractConverter {
}
// Map subtitles if present
if (!filterStreamsByType(streams, SubtitleStream.class).isEmpty()) {
if (hasInternalStreams(streams)) {
command.add("-map");
command.add("0:s");
command.add("-c:s");
@ -72,4 +72,20 @@ public class MkvH264Converter extends AbstractConverter {
return command.toArray(new String[0]);
}
/**
* Checks whether the processed file has any internal subtitle streams
*
* @param streams <p>All parsed streams for the video file</p>
* @return <p>True if the file has at least one internal subtitle stream</p>
*/
private boolean hasInternalStreams(List<StreamObject> streams) {
for (StreamObject subtitleStream : filterStreamsByType(streams, SubtitleStream.class)) {
if (((SubtitleStream) subtitleStream).isInternalSubtitle()) {
return true;
}
}
return false;
}
}