commit
89f2aa3bf1
@ -1,2 +1,10 @@
|
|||||||
.idea/
|
/node_modules
|
||||||
/node_modules
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|||||||
@ -1,114 +1,118 @@
|
|||||||
/* eslint-disable */
|
function details() {
|
||||||
function details () {
|
|
||||||
return {
|
return {
|
||||||
id: 'Tdarr_Plugin_henk_Add_Specific_Audio_Codec',
|
id: 'Tdarr_Plugin_henk_Add_Specific_Audio_Codec',
|
||||||
Stage: 'Pre-processing',
|
Stage: 'Pre-processing',
|
||||||
Name: '[TESTING][MKV ONLY] Transcode given codec to other given codec and keep original',
|
Name: '[TESTING][MKV ONLY] Transcode given codec to other given codec and keep original',
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
Operation: 'Transcode',
|
Operation: 'Transcode',
|
||||||
Description: `Re-encodes all audio tracks in a given codec to another given codec.`,
|
Description: 'Re-encodes all audio tracks in a given codec to another given codec and keeps original.',
|
||||||
Version: '1.00',
|
Version: '1.01',
|
||||||
Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_henk_Add_Specific_Audio_Codec.js',
|
Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/'
|
||||||
|
+ 'Tdarr_Plugin_henk_Add_Specific_Audio_Codec.js',
|
||||||
Tags: 'post-processing,configurable',
|
Tags: 'post-processing,configurable',
|
||||||
|
|
||||||
Inputs: [{
|
Inputs: [{
|
||||||
name: 'input_codecs',
|
name: 'input_codecs',
|
||||||
tooltip: 'Comma separated list of input codecs to be processed. Defaults to dts.' +
|
tooltip: 'Comma separated list of input codecs to be processed. Defaults to dts.'
|
||||||
'\\nExample:\\n' +
|
+ '\\nExample:\\n'
|
||||||
'dts,aac,ac3'
|
+ 'dts,aac,ac3',
|
||||||
}, {
|
}, {
|
||||||
name: 'output_codec',
|
name: 'output_codec',
|
||||||
tooltip: 'FFMPEG encoder used for the output of the new tracks. Defaults to ac3.'
|
tooltip: 'FFMPEG encoder used for the output of the new tracks. Defaults to ac3.',
|
||||||
}, {
|
}, {
|
||||||
name: 'bitrate',
|
name: 'bitrate',
|
||||||
tooltip: `Specifies the (stereo) bitrate for the new audio codec. Defaults to 128k. Only numbers.`
|
tooltip: 'Specifies the (stereo) bitrate for the new audio codec. Defaults to 128k. Only numbers.',
|
||||||
}, {
|
}, {
|
||||||
name: 'auto_adjust',
|
name: 'auto_adjust',
|
||||||
tooltip: '[true/false] Multi-channel audio requires a higher bitrate for the same quality, do you want the plugin to calculate this? (bitrate * (channels / 2))'
|
tooltip: '[true/false] Multi-channel audio requires a higher bitrate for the same quality, '
|
||||||
|
+ 'do you want the plugin to calculate this? (bitrate * (channels / 2))',
|
||||||
}, {
|
}, {
|
||||||
name: 'custom_bitrate_input',
|
name: 'custom_bitrate_input',
|
||||||
tooltip: 'DIRECT ACCESS TO FFMPEG, USE WITH CAUTION. If filled, can be used for custom bitrate arguments.'
|
tooltip: 'DIRECT ACCESS TO FFMPEG, USE WITH CAUTION. If filled, can be used for custom bitrate arguments.',
|
||||||
}],
|
}],
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function plugin (file, librarySettings, inputs) {
|
function plugin(file, librarySettings, inputs) {
|
||||||
var response = {
|
const response = {
|
||||||
processFile: false,
|
processFile: false,
|
||||||
preset: ', -c copy -map 0:v ',
|
preset: ', -c copy -map 0:v ',
|
||||||
container: '.' + file.container,
|
container: `.${file.container}`,
|
||||||
handBrakeMode: false,
|
handBrakeMode: false,
|
||||||
FFmpegMode: true,
|
FFmpegMode: true,
|
||||||
reQueueAfter: false,
|
reQueueAfter: false,
|
||||||
infoLog: '',
|
infoLog: '',
|
||||||
}
|
};
|
||||||
|
|
||||||
// Check if file is a video. If it isn't then exit plugin.
|
// Check if file is a video. If it isn't then exit plugin.
|
||||||
if (file.fileMedium !== 'video') {
|
if (file.fileMedium !== 'video') {
|
||||||
response.infoLog += '☒File is not video \n'
|
response.infoLog += '☒File is not video \n';
|
||||||
return response
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file is mkv. If it isn't then exit plugin.
|
// Check if file is mkv. If it isn't then exit plugin.
|
||||||
if (file.container !== 'mkv') {
|
if (file.container !== 'mkv') {
|
||||||
response.infoLog += '☒File is not mkv \n'
|
response.infoLog += '☒File is not mkv \n';
|
||||||
return response
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
var convertCount = 0
|
let convertCount = 0;
|
||||||
var streamCount = 0
|
let streamCount = 0;
|
||||||
var indexCount = 0
|
let indexCount = 0;
|
||||||
var killPlugin = false
|
let killPlugin = false;
|
||||||
var inputCodecs = inputs.input_codecs ? inputs.input_codecs.split(',') : ['dts']
|
const inputCodecs = inputs.input_codecs ? inputs.input_codecs.split(',') : ['dts'];
|
||||||
|
|
||||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||||
var currStream = file.ffProbeData.streams[i]
|
const currStream = file.ffProbeData.streams[i];
|
||||||
if (currStream.tags.COPYRIGHT) {
|
if (currStream.tags.COPYRIGHT) {
|
||||||
if (currStream.tags.COPYRIGHT === 'henk_asac') {
|
if (currStream.tags.COPYRIGHT === 'henk_asac') {
|
||||||
killPlugin = true
|
killPlugin = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (killPlugin) {
|
if (killPlugin) {
|
||||||
response.infoLog +=
|
response.infoLog
|
||||||
`☑File has already been processed by this plugin.\n`
|
+= '☑File has already been processed by this plugin.\n';
|
||||||
return response
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||||
var currStream = file.ffProbeData.streams[i]
|
const currStream = file.ffProbeData.streams[i];
|
||||||
if (currStream.codec_type.toLowerCase() === 'audio') {
|
if (currStream.codec_type.toLowerCase() === 'audio') {
|
||||||
response.preset += ` -map 0:a:${indexCount}? -c:a:${streamCount} copy `
|
response.preset += ` -map 0:a:${indexCount}? -c:a:${streamCount} copy `;
|
||||||
streamCount++
|
streamCount += 1;
|
||||||
|
|
||||||
if (inputCodecs.includes(currStream.codec_name.toLowerCase())) {
|
if (inputCodecs.includes(currStream.codec_name.toLowerCase())) {
|
||||||
convertCount++
|
convertCount += 1;
|
||||||
var bitrate = `-b:a:${streamCount} `
|
let bitrate = `-b:a:${streamCount} `;
|
||||||
if (inputs.custom_bitrate_input) {
|
if (inputs.custom_bitrate_input) {
|
||||||
bitrate += inputs.custom_bitrate_input
|
bitrate += inputs.custom_bitrate_input;
|
||||||
} else if (inputs.bitrate) {
|
} else if (inputs.bitrate) {
|
||||||
bitrate += (inputs.auto_adjust ? (inputs.bitrate * (currStream.channels / 2)) : inputs.bitrate) + 'k'
|
bitrate += `${inputs.auto_adjust ? (inputs.bitrate * (currStream.channels / 2)) : inputs.bitrate}k`;
|
||||||
} else {
|
} else {
|
||||||
bitrate = '128k'
|
bitrate = '128k';
|
||||||
}
|
}
|
||||||
response.preset += ` -map 0:a:${indexCount}? -c:a:${streamCount} ${inputs.output_codec || 'ac3'} ${bitrate} ` +
|
response.preset += ` -map 0:a:${indexCount}? -c:a:${streamCount} ${inputs.output_codec || 'ac3'} ${bitrate} `
|
||||||
`-metadata:s:a:${streamCount} title="" -metadata:s:a:${streamCount} copyright="henk_asac"`
|
+ `-metadata:s:a:${streamCount} title="" -metadata:s:a:${streamCount} copyright="henk_asac" `
|
||||||
|
+ `-disposition:a:${streamCount} 0`;
|
||||||
|
streamCount += 1;
|
||||||
}
|
}
|
||||||
indexCount++
|
indexCount += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertCount > 0) {
|
if (convertCount > 0) {
|
||||||
response.processFile = true
|
response.processFile = true;
|
||||||
response.container = '.' + file.container
|
response.container = `.${file.container}`;
|
||||||
response.reQueueAfter = true
|
response.reQueueAfter = true;
|
||||||
|
response.preset += ' -map 0:s ';
|
||||||
} else {
|
} else {
|
||||||
response.infoLog +=
|
response.infoLog
|
||||||
'☑File doesn\'t contain audio tracks with the specified codec.\n'
|
+= '☑File doesn\'t contain audio tracks with the specified codec.\n';
|
||||||
}
|
}
|
||||||
return response
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.details = details
|
module.exports.details = details;
|
||||||
module.exports.plugin = plugin
|
module.exports.plugin = plugin;
|
||||||
|
|||||||
Loading…
Reference in new issue