Add ability to keep commentary audio/subtitles

This commit is contained in:
MrMeeb 2024-04-27 20:16:46 +00:00
parent 7be5905cf9
commit ce72b90f68

View File

@ -47,6 +47,19 @@ const details = () => ({
}, },
tooltip: `Select whether to process subs, or just copy over`, tooltip: `Select whether to process subs, or just copy over`,
}, },
{
name: 'remove_commentary',
type: 'boolean',
defaultValue: true,
inputUI: {
type: 'dropdown',
options: [
'true',
'false',
],
},
tooltip: `Select whether to remove commentary audio and subtitle tracks`,
},
{ {
name: 'crf', name: 'crf',
type: 'string', // set the data type of the input ('string', 'number', 'boolean') type: 'string', // set the data type of the input ('string', 'number', 'boolean')
@ -168,13 +181,27 @@ const response = {
try { try {
if ( if (
file.ffProbeData.streams[i].tags.title != undefined && (file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") || file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1 file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == true
) { ) {
console.log(`Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Removing.`) console.log(`Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to remove.`)
response.infoLog += `Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Removing.\n` response.infoLog += `Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to remove.\n`
}
else if (
(file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == false
) {
console.log(`Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to keep.`)
response.infoLog += `Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to keep.\n`
ffmpegAudioOtherTracks += ` -map 0:a:${audioIdxTruehd}`
} }
@ -304,13 +331,27 @@ const response = {
// Identify if stream is commentary track // Identify if stream is commentary track
if ( if (
file.ffProbeData.streams[i].tags.title != undefined && (file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") || file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1 file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == true
) { ) {
console.log(`Stream ${i} (audio stream ${audioIdxDtshdma}) is probably a commentary track. Removing.`) console.log(`Stream ${i} (audio stream ${audioIdxDtshdma}) is probably a commentary track. Selected to remove.`)
response.infoLog += `Stream ${i} (audio stream ${audioIdxDtshdma}) is probably a commentary track. Removing.\n` response.infoLog += `Stream ${i} (audio stream ${audioIdxDtshdma}) is probably a commentary track. Selected to remove.\n`
}
else if (
(file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == false
) {
console.log(`Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to keep.`)
response.infoLog += `Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Selected to keep.\n`
ffmpegAudioOtherTracks += ` -map 0:a:${audioIdxTruehd}`
} }
@ -434,13 +475,27 @@ const response = {
try { try {
// Try to identify commentary tracks // Try to identify commentary tracks
if ( if (
file.ffProbeData.streams[i].tags.title != undefined && (file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") || file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1 file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == true
) { ) {
console.log(`Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Leaving it out`) console.log(`Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Selected to remove`)
response.infoLog += `Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Removing.\n` response.infoLog += `Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Selected to remove.\n`
}
else if (
(file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == false
) {
console.log(`Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Selected to keep.`)
response.infoLog += `Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Selected to keep.\n`
ffmpegAudioOtherTracks += ` -map 0:a:${audioIdx}`
} }
@ -649,8 +704,6 @@ const response = {
// Go through all subtitles, removing non-English/German subs and commentary subs // Go through all subtitles, removing non-English/German subs and commentary subs
for (let i = 0; i < file.ffProbeData.streams.length; i ++) { for (let i = 0; i < file.ffProbeData.streams.length; i ++) {
console.log(file.ffProbeData.streams[i].codec_type)
// Work with subtitle streams only // Work with subtitle streams only
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') { if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') {
@ -686,19 +739,33 @@ const response = {
// Remove any subtitles that are for commentary // Remove any subtitles that are for commentary
else if ( else if (
file.ffProbeData.streams[i].tags.title != undefined && (file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") || file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1 file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == true
) { ) {
console.log(`Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Removing.`) console.log(`Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Selected to remove.`)
response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Removing. \n` response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Selected to remove. \n`
ffmpegSubs += ` -map -0:s:${subIdx}` ffmpegSubs += ` -map -0:s:${subIdx}`
} }
else if (
(file.ffProbeData.streams[i].tags.title != undefined &&
file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary") ||
file.ffProbeData.streams[i].disposition.comment == 1) &&
inputs.remove_commentary == false
) {
console.log(`Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Selected to keep.`)
response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Selected to keep. \n`
}
else { else {
console.log(`Stream ${i} (subtitle stream ${subIdx}) is wanted. Keeping.`) console.log(`Stream ${i} (subtitle stream ${subIdx}) is wanted. Keeping.`)