Add ability to keep commentary audio/subtitles
This commit is contained in:
parent
7be5905cf9
commit
ce72b90f68
@ -47,6 +47,19 @@ const details = () => ({
|
||||
},
|
||||
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',
|
||||
type: 'string', // set the data type of the input ('string', 'number', 'boolean')
|
||||
@ -140,7 +153,7 @@ const response = {
|
||||
audioIdx++;
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
|
||||
// Identify wanted tracks
|
||||
try {
|
||||
|
||||
@ -161,20 +174,34 @@ const response = {
|
||||
|
||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') {
|
||||
|
||||
audioIdxTruehd++;
|
||||
audioIdxTruehd++;
|
||||
MMCodec = file.ffProbeData.streams[i].codec_name.toUpperCase();
|
||||
MMChannelLayout = file.ffProbeData.streams[i].channel_layout.replace('(side)', '');
|
||||
|
||||
try {
|
||||
|
||||
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].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.`)
|
||||
response.infoLog += `Stream ${i} (audio stream ${audioIdxTruehd}) is probably a commentary track. Removing.\n`
|
||||
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. 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
|
||||
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].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.`)
|
||||
response.infoLog += `Stream ${i} (audio stream ${audioIdxDtshdma}) is probably a commentary track. Removing.\n`
|
||||
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. 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,15 +475,29 @@ const response = {
|
||||
try {
|
||||
// Try to identify commentary tracks
|
||||
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].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`)
|
||||
response.infoLog += `Stream ${i} (audio stream ${audioIdx}) is probably a commentary track. Removing.\n`
|
||||
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. 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}`
|
||||
|
||||
}
|
||||
|
||||
else if (
|
||||
file.ffProbeData.streams[i].codec_name.toLowerCase() === 'ac3' &&
|
||||
@ -649,8 +704,6 @@ 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') {
|
||||
|
||||
@ -686,19 +739,33 @@ const response = {
|
||||
|
||||
// Remove any subtitles that are for commentary
|
||||
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].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.`)
|
||||
response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) is for a commentary track. Removing. \n`
|
||||
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. Selected to remove. \n`
|
||||
|
||||
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 {
|
||||
|
||||
console.log(`Stream ${i} (subtitle stream ${subIdx}) is wanted. Keeping.`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user