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`,
|
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')
|
||||||
@ -140,7 +153,7 @@ const response = {
|
|||||||
audioIdx++;
|
audioIdx++;
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
// Identify wanted tracks
|
// Identify wanted tracks
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -161,20 +174,34 @@ const response = {
|
|||||||
|
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') {
|
||||||
|
|
||||||
audioIdxTruehd++;
|
audioIdxTruehd++;
|
||||||
MMCodec = file.ffProbeData.streams[i].codec_name.toUpperCase();
|
MMCodec = file.ffProbeData.streams[i].codec_name.toUpperCase();
|
||||||
MMChannelLayout = file.ffProbeData.streams[i].channel_layout.replace('(side)', '');
|
MMChannelLayout = file.ffProbeData.streams[i].channel_layout.replace('(side)', '');
|
||||||
|
|
||||||
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,15 +475,29 @@ 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}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
else if (
|
else if (
|
||||||
file.ffProbeData.streams[i].codec_name.toLowerCase() === 'ac3' &&
|
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
|
// 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.`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user