parent
680916a6db
commit
2ba3df1977
@ -1,145 +1,144 @@
|
|||||||
const loadDefaultValues = require('../methods/loadDefaultValues');
|
const lib = require('../methods/library');
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
const details = () => {
|
const details = () => {
|
||||||
return {
|
return {
|
||||||
id: "Tdarr_Plugin_MP01_MichPasCleanSubsAndAudioCodecs",
|
id: "Tdarr_Plugin_MP01_MichPasCleanSubsAndAudioCodecs",
|
||||||
Stage: "Pre-processing",
|
Stage: "Pre-processing",
|
||||||
Name: "MichPass-Remove subtitle and audio streams with certain codecs",
|
Name: "MichPass-Remove subtitle and audio streams with certain codecs",
|
||||||
Type: "Any",
|
Type: "Any",
|
||||||
Operation: 'Transcode',
|
Operation: 'Transcode',
|
||||||
Description: `This plugin removed specified codecs from subtitle and audio tracks. Helpful to remove bitmap subtitles (pgs,vobsub) or audio codec (truehd), which can cause Plex to start transcoding. Based on Migz4 Plugin. Thanks \n\n`,
|
Description: `This plugin removed specified codecs from subtitle and audio tracks. Helpful to remove bitmap subtitles (pgs,vobsub) or audio codec (truehd), which can cause Plex to start transcoding. Based on Migz4 Plugin. Thanks \n\n`,
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Tags: "pre-processing,ffmpeg,subtitle, audio,configurable",
|
Tags: "pre-processing,ffmpeg,subtitle, audio,configurable",
|
||||||
|
|
||||||
Inputs: [
|
Inputs: [
|
||||||
{
|
{
|
||||||
name: "tag_subtitle_codecs",
|
name: "tag_subtitle_codecs",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `Specify key words here for subtitle tracks you'd like to have removed.
|
tooltip: `Specify key words here for subtitle tracks you'd like to have removed.
|
||||||
\\nExample:\\n
|
\\nExample:\\n
|
||||||
hdmv_pgs_subtitle
|
hdmv_pgs_subtitle
|
||||||
\\nExample:\\n
|
\\nExample:\\n
|
||||||
hdmv_pgs_subtitle,dvd_subtitle`,
|
hdmv_pgs_subtitle,dvd_subtitle`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "tag_audio_codecs",
|
name: "tag_audio_codecs",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `Specify all audio codecs you'd like to have removed.
|
tooltip: `Specify all audio codecs you'd like to have removed.
|
||||||
\\nExample:\\n
|
\\nExample:\\n
|
||||||
truehd
|
truehd
|
||||||
\\nExample:\\n
|
\\nExample:\\n
|
||||||
xxx,yyy`,
|
xxx,yyy`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||||
inputs = loadDefaultValues(inputs, details);
|
inputs = lib.loadDefaultValues(inputs, details);
|
||||||
var response = {
|
var response = {
|
||||||
processFile: false,
|
processFile: false,
|
||||||
preset: "",
|
preset: "",
|
||||||
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") {
|
||||||
console.log("File is not video");
|
console.log("File is not video");
|
||||||
response.infoLog += "☒File is not video \n";
|
response.infoLog += "☒File is not video \n";
|
||||||
response.processFile = false;
|
response.processFile = false;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set up required variables.
|
// Set up required variables.
|
||||||
var tag_subtitle_codecs = inputs.tag_subtitle_codecs.split(",");
|
var tag_subtitle_codecs = inputs.tag_subtitle_codecs.split(",");
|
||||||
var tag_audio_codecs = inputs.tag_audio_codecs.split(",");
|
var tag_audio_codecs = inputs.tag_audio_codecs.split(",");
|
||||||
var ffmpegCommandInsert = "";
|
var ffmpegCommandInsert = "";
|
||||||
var subtitleIdx = 0;
|
var subtitleIdx = 0;
|
||||||
var audioIdx = 0;
|
var audioIdx = 0;
|
||||||
var convert = false;
|
var convert = false;
|
||||||
|
|
||||||
// Go through each stream in the file.
|
// Go through each stream in the file.
|
||||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
||||||
// Catch error here incase the title metadata is completely missing.
|
// Catch error here incase the title metadata is completely missing.
|
||||||
try {
|
try {
|
||||||
// Check stream is subtitle AND stream codec contains certain words, removing these streams .
|
// Check stream is subtitle AND stream codec contains certain words, removing these streams .
|
||||||
if (
|
if (
|
||||||
file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle" &&
|
file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle" &&
|
||||||
tag_subtitle_codecs.indexOf(file.ffProbeData.streams[i].codec_name.toLowerCase()
|
tag_subtitle_codecs.indexOf(file.ffProbeData.streams[i].codec_name.toLowerCase()
|
||||||
) > -1
|
) > -1
|
||||||
) {
|
) {
|
||||||
ffmpegCommandInsert += `-map -0:s:${subtitleIdx} `;
|
ffmpegCommandInsert += `-map -0:s:${subtitleIdx} `;
|
||||||
response.infoLog += `☒Subtitle stream detected as unwanted. removing subtitle stream 0:s:${subtitleIdx} - ${file.ffProbeData.streams[i].tags.title} - ${file.ffProbeData.streams[i].codec_name}. \n`;
|
response.infoLog += `☒Subtitle stream detected as unwanted. removing subtitle stream 0:s:${subtitleIdx} - ${file.ffProbeData.streams[i].tags.title} - ${file.ffProbeData.streams[i].codec_name}. \n`;
|
||||||
convert = true;
|
convert = true;
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
// response.infoLog += `☒test tags codectype title - ${file.ffProbeData.streams[i].codec_type}. \n`;
|
// response.infoLog += `☒test tags codectype title - ${file.ffProbeData.streams[i].codec_type}. \n`;
|
||||||
// response.infoLog += `☒test tag name - ${file.ffProbeData.streams[i].codec_name}. \n`;
|
// response.infoLog += `☒test tag name - ${file.ffProbeData.streams[i].codec_name}. \n`;
|
||||||
// response.infoLog += `☒test tags long name - ${file.ffProbeData.streams[i].codec_long_name}. \n`;
|
// response.infoLog += `☒test tags long name - ${file.ffProbeData.streams[i].codec_long_name}. \n`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if stream is audio .
|
// Check if stream is audio .
|
||||||
if (
|
if (
|
||||||
file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" &&
|
file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" &&
|
||||||
tag_audio_codecs.indexOf(file.ffProbeData.streams[i].codec_name.toLowerCase()
|
tag_audio_codecs.indexOf(file.ffProbeData.streams[i].codec_name.toLowerCase()
|
||||||
) > -1
|
) > -1
|
||||||
) {
|
) {
|
||||||
ffmpegCommandInsert += `-map -0:a:${audioIdx} `;
|
ffmpegCommandInsert += `-map -0:a:${audioIdx} `;
|
||||||
response.infoLog += `☒audio stream detected as unwanted. removing audio stream 0:a:${audioIdx} - ${file.ffProbeData.streams[i].tags.title} - ${file.ffProbeData.streams[i].codec_name} \n`;
|
response.infoLog += `☒audio stream detected as unwanted. removing audio stream 0:a:${audioIdx} - ${file.ffProbeData.streams[i].tags.title} - ${file.ffProbeData.streams[i].codec_name} \n`;
|
||||||
convert = true;
|
convert = true;
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
|
|
||||||
// Check if stream type is audio and increment audioIdx if true.
|
// Check if stream type is audio and increment audioIdx if true.
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
||||||
audioIdx++;
|
audioIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if stream type is subtitle and increment subtitleIdx if true.
|
// Check if stream type is subtitle and increment subtitleIdx if true.
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
|
||||||
subtitleIdx++;
|
subtitleIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert file if convert variable is set to true.
|
// Convert file if convert variable is set to true.
|
||||||
|
|
||||||
if (convert === true) {
|
if (convert === true) {
|
||||||
response.processFile = true;
|
response.processFile = true;
|
||||||
response.preset = `, -map 0 ${ffmpegCommandInsert} -c copy -max_muxing_queue_size 4096`;
|
response.preset = `, -map 0 ${ffmpegCommandInsert} -c copy -max_muxing_queue_size 4096`;
|
||||||
response.container = "." + file.container;
|
response.container = "." + file.container;
|
||||||
response.reQueueAfter = true;
|
response.reQueueAfter = true;
|
||||||
} else {
|
} else {
|
||||||
response.processFile = false;
|
response.processFile = false;
|
||||||
response.infoLog +=
|
response.infoLog +=
|
||||||
"☑File doesn't contain subtitle or audio codecs which were unwanted or that require tagging.\n";
|
"☑File doesn't contain subtitle or audio codecs which were unwanted or that require tagging.\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.details = details;
|
module.exports.details = details;
|
||||||
module.exports.plugin = plugin;
|
module.exports.plugin = plugin;
|
||||||
@ -1,232 +1,232 @@
|
|||||||
const loadDefaultValues = require('../methods/loadDefaultValues');
|
const lib = require('../methods/library');
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
//PLugin runs multipass loudnorm filter
|
//PLugin runs multipass loudnorm filter
|
||||||
//first run gets the required details and stores for the next pass
|
//first run gets the required details and stores for the next pass
|
||||||
//second pass applies the values
|
//second pass applies the values
|
||||||
|
|
||||||
//stages
|
//stages
|
||||||
// Determined Loudnorm Values
|
// Determined Loudnorm Values
|
||||||
// Applying Normalisation
|
// Applying Normalisation
|
||||||
// Normalisation Complete
|
// Normalisation Complete
|
||||||
|
|
||||||
|
|
||||||
//setup global vars
|
//setup global vars
|
||||||
|
|
||||||
var secondPass = false;
|
var secondPass = false;
|
||||||
var logOutFile = '';
|
var logOutFile = '';
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
const details = () => {
|
const details = () => {
|
||||||
return {
|
return {
|
||||||
id: "Tdarr_Plugin_NIfPZuCLU_2_Pass_Loudnorm_Audio_Normalisation",
|
id: "Tdarr_Plugin_NIfPZuCLU_2_Pass_Loudnorm_Audio_Normalisation",
|
||||||
Stage: 'Pre-processing',
|
Stage: 'Pre-processing',
|
||||||
Name: "2 Pass Loudnorm Volume Normalisation",
|
Name: "2 Pass Loudnorm Volume Normalisation",
|
||||||
Type: "Video",
|
Type: "Video",
|
||||||
Operation: "Transcode",
|
Operation: "Transcode",
|
||||||
Description: "PLEASE READ FULL DESCRIPTION BEFORE USE \n Uses multiple passes to normalise audio streams of videos using loudnorm.\n\n The first pass will create an log file in the same directory as the video.\nSecond pass will apply the values determined in the first pass to the file.\nOutput will be MKV to allow metadata to be added for tracking normalisation stage.",
|
Description: "PLEASE READ FULL DESCRIPTION BEFORE USE \n Uses multiple passes to normalise audio streams of videos using loudnorm.\n\n The first pass will create an log file in the same directory as the video.\nSecond pass will apply the values determined in the first pass to the file.\nOutput will be MKV to allow metadata to be added for tracking normalisation stage.",
|
||||||
Version: "0.1",
|
Version: "0.1",
|
||||||
Tags: "pre-processing,ffmpeg,configurable",
|
Tags: "pre-processing,ffmpeg,configurable",
|
||||||
|
|
||||||
Inputs: [
|
Inputs: [
|
||||||
//(Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI
|
//(Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI
|
||||||
{
|
{
|
||||||
name: "i",
|
name: "i",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue:'-23.0',
|
defaultValue:'-23.0',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `\"I\" value used in loudnorm pass \n
|
tooltip: `\"I\" value used in loudnorm pass \n
|
||||||
defaults to -23.0`, //Each line following `Example:` will be clearly formatted. \\n used for line breaks
|
defaults to -23.0`, //Each line following `Example:` will be clearly formatted. \\n used for line breaks
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "lra",
|
name: "lra",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue:'7.0',
|
defaultValue:'7.0',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `Desired lra value. \n Defaults to 7.0
|
tooltip: `Desired lra value. \n Defaults to 7.0
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tp",
|
name: "tp",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue:'-2.0',
|
defaultValue:'-2.0',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `Desired \"tp\" value. \n Defaults to -2.0
|
tooltip: `Desired \"tp\" value. \n Defaults to -2.0
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "offset",
|
name: "offset",
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue:'0.0',
|
defaultValue:'0.0',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
tooltip: `Desired "offset" value. \n Defaults to 0.0
|
tooltip: `Desired "offset" value. \n Defaults to 0.0
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||||
inputs = loadDefaultValues(inputs, details);
|
inputs = lib.loadDefaultValues(inputs, details);
|
||||||
|
|
||||||
//Must return this object at some point
|
//Must return this object at some point
|
||||||
var response = {
|
var response = {
|
||||||
processFile: false,
|
processFile: false,
|
||||||
preset: '',
|
preset: '',
|
||||||
container: '.mkv',
|
container: '.mkv',
|
||||||
handBrakeMode: false,
|
handBrakeMode: false,
|
||||||
FFmpegMode: true,
|
FFmpegMode: true,
|
||||||
reQueueAfter: true,
|
reQueueAfter: true,
|
||||||
infoLog: '',
|
infoLog: '',
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.infoLog += ""
|
response.infoLog += ""
|
||||||
//grab the current file being processed and make an out file for the ffmpeg log
|
//grab the current file being processed and make an out file for the ffmpeg log
|
||||||
let currentfilename = file._id;
|
let currentfilename = file._id;
|
||||||
logOutFile = currentfilename.substr(0, currentfilename.lastIndexOf(".")) + ".out"
|
logOutFile = currentfilename.substr(0, currentfilename.lastIndexOf(".")) + ".out"
|
||||||
console.log("Log out file: " + logOutFile)
|
console.log("Log out file: " + logOutFile)
|
||||||
|
|
||||||
//get an updated version of the file for checking metadata
|
//get an updated version of the file for checking metadata
|
||||||
var probeData = JSON.parse(require("child_process").execSync(`ffprobe -v quiet -print_format json -show_format -show_streams "${currentfilename}"`).toString())
|
var probeData = JSON.parse(require("child_process").execSync(`ffprobe -v quiet -print_format json -show_format -show_streams "${currentfilename}"`).toString())
|
||||||
|
|
||||||
//setup required varibles
|
//setup required varibles
|
||||||
var loudNorm_i = -23.0
|
var loudNorm_i = -23.0
|
||||||
var lra = 7.0
|
var lra = 7.0
|
||||||
var tp = -2.0
|
var tp = -2.0
|
||||||
var offset = 0.0
|
var offset = 0.0
|
||||||
|
|
||||||
//create local varibles for inputs
|
//create local varibles for inputs
|
||||||
if (inputs !== undefined) {
|
if (inputs !== undefined) {
|
||||||
if (inputs.i !== undefined) loudNorm_i = inputs.i
|
if (inputs.i !== undefined) loudNorm_i = inputs.i
|
||||||
if (inputs.lra !== undefined) lra = inputs.lra
|
if (inputs.lra !== undefined) lra = inputs.lra
|
||||||
if (inputs.tp !== undefined) tp = inputs.tp
|
if (inputs.tp !== undefined) tp = inputs.tp
|
||||||
if (inputs.offset !== undefined) offset = inputs.offset
|
if (inputs.offset !== undefined) offset = inputs.offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//check for previous pass tags
|
//check for previous pass tags
|
||||||
|
|
||||||
if (typeof probeData.format === "undefined" || typeof probeData.format.tags.NORMALISATIONSTAGE === "undefined" || probeData.format.tags.NORMALISATIONSTAGE === "" || file.forceProcessing === true) {
|
if (typeof probeData.format === "undefined" || typeof probeData.format.tags.NORMALISATIONSTAGE === "undefined" || probeData.format.tags.NORMALISATIONSTAGE === "" || file.forceProcessing === true) {
|
||||||
|
|
||||||
//no metadata found first pass is required
|
//no metadata found first pass is required
|
||||||
console.log("Searching for audio normailisation values")
|
console.log("Searching for audio normailisation values")
|
||||||
response.infoLog += "Searching for required normalisation values. \n"
|
response.infoLog += "Searching for required normalisation values. \n"
|
||||||
var loudNormInfo = "";
|
var loudNormInfo = "";
|
||||||
|
|
||||||
//Do the first pass, output the log to the out file and use a secondary output for an unchanged file to allow Tdarr to track, Set metadata stage
|
//Do the first pass, output the log to the out file and use a secondary output for an unchanged file to allow Tdarr to track, Set metadata stage
|
||||||
response.preset = `<io>-af loudnorm=I=${loudNorm_i}:LRA=${lra}:TP=${tp}:print_format=json -f null NUL -map 0 -c copy -metadata NORMALISATIONSTAGE="FirstPassComplete" 2>"${logOutFile}"`
|
response.preset = `<io>-af loudnorm=I=${loudNorm_i}:LRA=${lra}:TP=${tp}:print_format=json -f null NUL -map 0 -c copy -metadata NORMALISATIONSTAGE="FirstPassComplete" 2>"${logOutFile}"`
|
||||||
response.container = '.mkv'
|
response.container = '.mkv'
|
||||||
response.handBrakeMode = false
|
response.handBrakeMode = false
|
||||||
response.FFmpegMode = true
|
response.FFmpegMode = true
|
||||||
response.reQueueAfter = true;
|
response.reQueueAfter = true;
|
||||||
response.processFile = true
|
response.processFile = true
|
||||||
response.infoLog += "Normalisation first pass processing \n"
|
response.infoLog += "Normalisation first pass processing \n"
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
if (probeData.format.tags.NORMALISATIONSTAGE === "FirstPassComplete") {
|
if (probeData.format.tags.NORMALISATIONSTAGE === "FirstPassComplete") {
|
||||||
|
|
||||||
//ensure previous out file exists
|
//ensure previous out file exists
|
||||||
if (fs.existsSync(logOutFile)) {
|
if (fs.existsSync(logOutFile)) {
|
||||||
secondPass = true;
|
secondPass = true;
|
||||||
loudNormInfo = fs.readFileSync(logOutFile).toString();
|
loudNormInfo = fs.readFileSync(logOutFile).toString();
|
||||||
|
|
||||||
//grab the json from the out file
|
//grab the json from the out file
|
||||||
var startIndex = loudNormInfo.lastIndexOf("{");
|
var startIndex = loudNormInfo.lastIndexOf("{");
|
||||||
var endIndex = loudNormInfo.lastIndexOf("}");
|
var endIndex = loudNormInfo.lastIndexOf("}");
|
||||||
|
|
||||||
var outValues = loudNormInfo.toString().substr(startIndex, endIndex)
|
var outValues = loudNormInfo.toString().substr(startIndex, endIndex)
|
||||||
|
|
||||||
response.infoLog += "Loudnorm first pass values returned: \n" + outValues
|
response.infoLog += "Loudnorm first pass values returned: \n" + outValues
|
||||||
|
|
||||||
//parse the JSON
|
//parse the JSON
|
||||||
var loudNormValues = JSON.parse(outValues)
|
var loudNormValues = JSON.parse(outValues)
|
||||||
|
|
||||||
//use parsed values in second pass
|
//use parsed values in second pass
|
||||||
response.preset = `-y<io>-af loudnorm=print_format=summary:linear=true:I=${loudNorm_i}:LRA=${lra}:TP=${tp}:measured_i=${loudNormValues.input_i}:measured_lra=${loudNormValues.input_lra}:measured_tp=${loudNormValues.input_tp}:measured_thresh=${loudNormValues.input_thresh}:offset=${loudNormValues.target_offset} -c:a aac -b:a 192k -c:s copy -c:v copy -metadata NORMALISATIONSTAGE="Complete"`
|
response.preset = `-y<io>-af loudnorm=print_format=summary:linear=true:I=${loudNorm_i}:LRA=${lra}:TP=${tp}:measured_i=${loudNormValues.input_i}:measured_lra=${loudNormValues.input_lra}:measured_tp=${loudNormValues.input_tp}:measured_thresh=${loudNormValues.input_thresh}:offset=${loudNormValues.target_offset} -c:a aac -b:a 192k -c:s copy -c:v copy -metadata NORMALISATIONSTAGE="Complete"`
|
||||||
response.container = '.mkv'
|
response.container = '.mkv'
|
||||||
response.handBrakeMode = false
|
response.handBrakeMode = false
|
||||||
response.FFmpegMode = true
|
response.FFmpegMode = true
|
||||||
response.reQueueAfter = true;
|
response.reQueueAfter = true;
|
||||||
response.processFile = true
|
response.processFile = true
|
||||||
response.infoLog += "Normalisation pass processing \n"
|
response.infoLog += "Normalisation pass processing \n"
|
||||||
return response
|
return response
|
||||||
} else {
|
} else {
|
||||||
response.infoLog += "Previous log output file is missing. Please rerun with force processing to regenerate."
|
response.infoLog += "Previous log output file is missing. Please rerun with force processing to regenerate."
|
||||||
response.processFile = false;
|
response.processFile = false;
|
||||||
return response
|
return response
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(probeData.format.tags.NORMALISATIONSTAGE === "Complete"){
|
if(probeData.format.tags.NORMALISATIONSTAGE === "Complete"){
|
||||||
response.processFile = false;
|
response.processFile = false;
|
||||||
response.infoLog += "File is already marked as normalised \n"
|
response.infoLog += "File is already marked as normalised \n"
|
||||||
return response
|
return response
|
||||||
} else {
|
} else {
|
||||||
//what is this tag?
|
//what is this tag?
|
||||||
response.processFile = false;
|
response.processFile = false;
|
||||||
response.infoLog += "Unknown normalisation stage tag: \n" + probeData.format.tags.NORMALISATIONSTAGE
|
response.infoLog += "Unknown normalisation stage tag: \n" + probeData.format.tags.NORMALISATIONSTAGE
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.onTranscodeSuccess = function onTranscodeSuccess(
|
module.exports.onTranscodeSuccess = function onTranscodeSuccess(
|
||||||
file,
|
file,
|
||||||
librarySettings,
|
librarySettings,
|
||||||
inputs
|
inputs
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var response = {
|
var response = {
|
||||||
file,
|
file,
|
||||||
removeFromDB: false,
|
removeFromDB: false,
|
||||||
updateDB: true,
|
updateDB: true,
|
||||||
};
|
};
|
||||||
if (secondPass) {
|
if (secondPass) {
|
||||||
response.infoLog += "Audio normalisation complete. \n"
|
response.infoLog += "Audio normalisation complete. \n"
|
||||||
//remove old out file
|
//remove old out file
|
||||||
if (fs.existsSync(logOutFile)) {
|
if (fs.existsSync(logOutFile)) {
|
||||||
fs.unlinkSync(logOutFile);
|
fs.unlinkSync(logOutFile);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
response.infoLog += "Audio normalisation first pass complete. \n"
|
response.infoLog += "Audio normalisation first pass complete. \n"
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.onTranscodeError = function onTranscodeError(
|
module.exports.onTranscodeError = function onTranscodeError(
|
||||||
file,
|
file,
|
||||||
librarySettings,
|
librarySettings,
|
||||||
inputs
|
inputs
|
||||||
) {
|
) {
|
||||||
console.log("Failed to normalise audio");
|
console.log("Failed to normalise audio");
|
||||||
|
|
||||||
//Optional response if you need to modify database
|
//Optional response if you need to modify database
|
||||||
var response = {
|
var response = {
|
||||||
file,
|
file,
|
||||||
removeFromDB: false,
|
removeFromDB: false,
|
||||||
updateDB: false,
|
updateDB: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.details = details;
|
module.exports.details = details;
|
||||||
module.exports.plugin = plugin;
|
module.exports.plugin = plugin;
|
||||||
@ -1,63 +1,60 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
const loadDefaultValues = require('../methods/loadDefaultValues');
|
const lib = require('../methods/library');
|
||||||
if (fs.existsSync(path.join(process.cwd(), '/npm'))) {
|
if (fs.existsSync(path.join(process.cwd(), '/npm'))) {
|
||||||
var rootModules = path.join(process.cwd(), '/npm/node_modules/')
|
var rootModules = path.join(process.cwd(), '/npm/node_modules/')
|
||||||
} else {
|
} else {
|
||||||
var rootModules = ''
|
var rootModules = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const importFresh = require(rootModules + 'import-fresh');
|
const details = () => {
|
||||||
const library = importFresh('../methods/library.js')
|
return {
|
||||||
|
id: "Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid",
|
||||||
const details = () => {
|
Stage: 'Pre-processing',
|
||||||
return {
|
Name: "Set file permissions for UnRaid",
|
||||||
id: "Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid",
|
Type: "Video",
|
||||||
Stage: 'Pre-processing',
|
Operation: "Transcode",
|
||||||
Name: "Set file permissions for UnRaid",
|
Description: "Sets file permissions using chown nobody:users to prevent lock from root. Use at end of stack. ",
|
||||||
Type: "Video",
|
Version: "",
|
||||||
Operation: "Transcode",
|
Tags: "post-processing",
|
||||||
Description: "Sets file permissions using chown nobody:users to prevent lock from root. Use at end of stack. ",
|
Inputs:[],
|
||||||
Version: "",
|
}
|
||||||
Tags: "post-processing",
|
}
|
||||||
Inputs:[],
|
|
||||||
}
|
// eslint-disable-next-line no-unused-vars
|
||||||
}
|
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
|
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||||
// eslint-disable-next-line no-unused-vars
|
inputs = lib.loadDefaultValues(inputs, details);
|
||||||
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|
||||||
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
//Must return this object at some point
|
||||||
inputs = loadDefaultValues(inputs, details);
|
var response = {
|
||||||
|
processFile: false,
|
||||||
//Must return this object at some point
|
preset: '',
|
||||||
var response = {
|
container: '.mkv',
|
||||||
processFile: false,
|
handBrakeMode: false,
|
||||||
preset: '',
|
FFmpegMode: true,
|
||||||
container: '.mkv',
|
reQueueAfter: true,
|
||||||
handBrakeMode: false,
|
infoLog: '',
|
||||||
FFmpegMode: true,
|
|
||||||
reQueueAfter: true,
|
}
|
||||||
infoLog: '',
|
|
||||||
|
response.infoLog += ""
|
||||||
}
|
|
||||||
|
if ((true) || file.forceProcessing === true) {
|
||||||
response.infoLog += ""
|
|
||||||
|
require("child_process").execSync(`chown nobody:users "${file._id}"`)
|
||||||
if ((true) || file.forceProcessing === true) {
|
response.preset = ''
|
||||||
|
response.container = '.mkv'
|
||||||
require("child_process").execSync(`chown nobody:users "${file._id}"`)
|
response.handBrakeMode = false
|
||||||
response.preset = ''
|
response.FFmpegMode = true
|
||||||
response.container = '.mkv'
|
response.reQueueAfter = true;
|
||||||
response.handBrakeMode = false
|
response.processFile = false
|
||||||
response.FFmpegMode = true
|
response.infoLog += "File permissions set \n"
|
||||||
response.reQueueAfter = true;
|
return response
|
||||||
response.processFile = false
|
}
|
||||||
response.infoLog += "File permissions set \n"
|
}
|
||||||
return response
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.details = details;
|
module.exports.details = details;
|
||||||
module.exports.plugin = plugin;
|
module.exports.plugin = plugin;
|
||||||
Loading…
Reference in new issue