Add detection for subtitles with no language. Fixes error where processing halts in subtitles with no language

This commit is contained in:
MrMeeb 2024-04-21 20:06:51 +00:00
parent f3aca08aea
commit 7be5905cf9

View File

@ -649,11 +649,11 @@ const response = {
// Go through all subtitles, removing non-English/German subs and commentary subs
for (let i = 0; i < file.ffProbeData.streams.length; i ++) {
console.log(file.ffProbeData.streams[i].codec_type)
// Work with subtitle streams only
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') {
//console.log(`Stream ${i} is a subtitle stream`);
// Keep track of subtitle stream relative numbers
try {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
@ -661,10 +661,18 @@ const response = {
}
} catch (err) {}
//console.log(`language = ${file.ffProbeData.streams[i].tags.language.toLowerCase()}`)
// Remove any subtitles with no language set
if (file.ffProbeData.streams[i].tags.language == undefined) {
console.log(`Stream ${i} (subtitle stream ${subIdx}) has no language. Removing.`)
response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) has no language. Removing. \n`
ffmpegSubs += ` -map -0:s:${subIdx}`
}
// Remove any subtitles not in English or German
if (
else if (
file.ffProbeData.streams[i].tags.language.toLowerCase() !== "eng" &&
file.ffProbeData.streams[i].tags.language.toLowerCase() !== "ger"
) {