From 16afcf09bfe7fdaf3b68b78ce08163dd6e6db036 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Mon, 22 Aug 2022 02:05:55 +0100 Subject: [PATCH 1/3] Add 10 bit video filter --- .../Tdarr_Plugin_00td_filter_10_bit_video.js | 56 ++++++++++++++++++ .../Tdarr_Plugin_00td_filter_10_bit_video.js | 58 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 Community/Tdarr_Plugin_00td_filter_10_bit_video.js create mode 100644 tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js diff --git a/Community/Tdarr_Plugin_00td_filter_10_bit_video.js b/Community/Tdarr_Plugin_00td_filter_10_bit_video.js new file mode 100644 index 0000000..89ff8d1 --- /dev/null +++ b/Community/Tdarr_Plugin_00td_filter_10_bit_video.js @@ -0,0 +1,56 @@ +const details = () => ({ + id: 'Tdarr_Plugin_00td_filter_10_bit_video', + Stage: 'Pre-processing', + Name: 'Filter 10 bit video', + Type: 'Video', + Operation: 'Filter', + Description: 'Allow/disallow 10 bit video to be processed.', + Version: '1.00', + Tags: 'filter', + Inputs: [ + { + name: 'process10BitVideo', + type: 'boolean', + defaultValue: false, + inputUI: { + type: 'dropdown', + options: [ + 'false', + 'true', + ], + }, + tooltip: 'Set true to allow 10 bit video to be processed.', + }, + ], +}); + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + const response = { + processFile: true, + infoLog: 'File will be processed.', + }; + + try { + const streams10Bit = file.ffProbeData.streams.filter((row) => row.profile === 'Main 10'); + if (inputs.process10BitVideo === false && streams10Bit.length > 0) { + response.processFile = false; + response.infoLog = 'File video is 10 bit but 10 bit video processing is not allowed. Skipping plugins.'; + } else if (inputs.process10BitVideo === true && streams10Bit.length > 0) { + response.infoLog = 'File video is 10 bit and 10 bit video processing is allowed. Continuing to plugins'; + } else if (streams10Bit.length === 0) { + response.infoLog += 'File is not 10 bit.'; + } + } catch (err) { + // eslint-disable-next-line no-console + console.log(err); + } + + return response; +}; + +module.exports.details = details; +module.exports.plugin = plugin; diff --git a/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js b/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js new file mode 100644 index 0000000..d5f9cb7 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js @@ -0,0 +1,58 @@ +/* eslint max-len: 0 */ +const _ = require('lodash'); +const run = require('../helpers/run'); + +const tests = [ + { + input: { + file: require('../sampleData/media/sampleH264_1.json'), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File will be processed.File is not 10 bit.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 10'; + return file; + })(), + librarySettings: {}, + inputs: { + process10BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 10 bit but 10 bit video processing is not allowed. Skipping plugins.', + }, + }, + + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 10'; + return file; + })(), + librarySettings: {}, + inputs: { + process10BitVideo: true, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 10 bit and 10 bit video processing is allowed. Continuing to plugins', + }, + }, + +]; + +run(tests); From 3dc2d1a322c01c8f68799114892d1fbd061e7b2a Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sun, 28 Aug 2022 03:52:59 +0100 Subject: [PATCH 2/3] Update plugin --- .../Tdarr_Plugin_00td_filter_10_bit_video.js | 56 ---- .../Tdarr_Plugin_00td_filter_bit_depth.js | 100 ++++++++ .../Tdarr_Plugin_00td_filter_10_bit_video.js | 58 ----- .../Tdarr_Plugin_00td_filter_bit_depth.js | 242 ++++++++++++++++++ 4 files changed, 342 insertions(+), 114 deletions(-) delete mode 100644 Community/Tdarr_Plugin_00td_filter_10_bit_video.js create mode 100644 Community/Tdarr_Plugin_00td_filter_bit_depth.js delete mode 100644 tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js create mode 100644 tests/Community/Tdarr_Plugin_00td_filter_bit_depth.js diff --git a/Community/Tdarr_Plugin_00td_filter_10_bit_video.js b/Community/Tdarr_Plugin_00td_filter_10_bit_video.js deleted file mode 100644 index 89ff8d1..0000000 --- a/Community/Tdarr_Plugin_00td_filter_10_bit_video.js +++ /dev/null @@ -1,56 +0,0 @@ -const details = () => ({ - id: 'Tdarr_Plugin_00td_filter_10_bit_video', - Stage: 'Pre-processing', - Name: 'Filter 10 bit video', - Type: 'Video', - Operation: 'Filter', - Description: 'Allow/disallow 10 bit video to be processed.', - Version: '1.00', - Tags: 'filter', - Inputs: [ - { - name: 'process10BitVideo', - type: 'boolean', - defaultValue: false, - inputUI: { - type: 'dropdown', - options: [ - 'false', - 'true', - ], - }, - tooltip: 'Set true to allow 10 bit video to be processed.', - }, - ], -}); - -// eslint-disable-next-line no-unused-vars -const plugin = (file, librarySettings, inputs, otherArguments) => { - const lib = require('../methods/lib')(); - // eslint-disable-next-line no-unused-vars,no-param-reassign - inputs = lib.loadDefaultValues(inputs, details); - const response = { - processFile: true, - infoLog: 'File will be processed.', - }; - - try { - const streams10Bit = file.ffProbeData.streams.filter((row) => row.profile === 'Main 10'); - if (inputs.process10BitVideo === false && streams10Bit.length > 0) { - response.processFile = false; - response.infoLog = 'File video is 10 bit but 10 bit video processing is not allowed. Skipping plugins.'; - } else if (inputs.process10BitVideo === true && streams10Bit.length > 0) { - response.infoLog = 'File video is 10 bit and 10 bit video processing is allowed. Continuing to plugins'; - } else if (streams10Bit.length === 0) { - response.infoLog += 'File is not 10 bit.'; - } - } catch (err) { - // eslint-disable-next-line no-console - console.log(err); - } - - return response; -}; - -module.exports.details = details; -module.exports.plugin = plugin; diff --git a/Community/Tdarr_Plugin_00td_filter_bit_depth.js b/Community/Tdarr_Plugin_00td_filter_bit_depth.js new file mode 100644 index 0000000..07921e5 --- /dev/null +++ b/Community/Tdarr_Plugin_00td_filter_bit_depth.js @@ -0,0 +1,100 @@ +const details = () => ({ + id: 'Tdarr_Plugin_00td_filter_bit_depth', + Stage: 'Pre-processing', + Name: 'Filter bit depth: 8,10,12 bit video', + Type: 'Video', + Operation: 'Filter', + Description: 'Allow/disallow 8,10,12 bit video to be processed.', + Version: '1.00', + Tags: 'filter', + Inputs: [ + { + name: 'process8BitVideo', + type: 'boolean', + defaultValue: true, + inputUI: { + type: 'dropdown', + options: [ + 'false', + 'true', + ], + }, + tooltip: 'Set true to allow 8 bit video to be processed.', + }, + { + name: 'process10BitVideo', + type: 'boolean', + defaultValue: true, + inputUI: { + type: 'dropdown', + options: [ + 'false', + 'true', + ], + }, + tooltip: 'Set true to allow 10 bit video to be processed.', + }, + { + name: 'process12BitVideo', + type: 'boolean', + defaultValue: true, + inputUI: { + type: 'dropdown', + options: [ + 'false', + 'true', + ], + }, + tooltip: 'Set true to allow 12 bit video to be processed.', + }, + ], +}); + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + const response = { + processFile: false, + infoLog: '', + }; + + const bitDepths = { + 8: 'Main', + 10: 'Main 10', + 12: 'Main 12', + }; + + let foundBitDepth = false; + Object.keys(bitDepths).forEach((bitDepth) => { + try { + const fileHasSpecifiedBitDepth = file.ffProbeData.streams + .filter((row) => row.bits_per_raw_sample === bitDepth).length > 0 + || file.ffProbeData.streams.filter((row) => row.profile === bitDepths[bitDepth]).length > 0; + + if (fileHasSpecifiedBitDepth) { + foundBitDepth = true; + response.infoLog += `File video is ${bitDepth} bit.`; + if (inputs[`process${bitDepth}BitVideo`]) { + response.processFile = true; + response.infoLog += ` ${bitDepth} bit is allowed, will process.`; + } else { + response.infoLog += ` ${bitDepth} bit is not allowed, will not process.`; + } + } + } catch (err) { + // eslint-disable-next-line no-console + console.log(err); + } + }); + + if (!foundBitDepth) { + response.infoLog += ' Unable to find file bit depth. Won\'t process.'; + } + + return response; +}; + +module.exports.details = details; +module.exports.plugin = plugin; diff --git a/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js b/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js deleted file mode 100644 index d5f9cb7..0000000 --- a/tests/Community/Tdarr_Plugin_00td_filter_10_bit_video.js +++ /dev/null @@ -1,58 +0,0 @@ -/* eslint max-len: 0 */ -const _ = require('lodash'); -const run = require('../helpers/run'); - -const tests = [ - { - input: { - file: require('../sampleData/media/sampleH264_1.json'), - librarySettings: {}, - inputs: {}, - otherArguments: {}, - }, - output: { - processFile: true, - infoLog: 'File will be processed.File is not 10 bit.', - }, - }, - { - input: { - file: (() => { - const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); - file.ffProbeData.streams[0].profile = 'Main 10'; - return file; - })(), - librarySettings: {}, - inputs: { - process10BitVideo: false, - }, - otherArguments: {}, - }, - output: { - processFile: false, - infoLog: 'File video is 10 bit but 10 bit video processing is not allowed. Skipping plugins.', - }, - }, - - { - input: { - file: (() => { - const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); - file.ffProbeData.streams[0].profile = 'Main 10'; - return file; - })(), - librarySettings: {}, - inputs: { - process10BitVideo: true, - }, - otherArguments: {}, - }, - output: { - processFile: true, - infoLog: 'File video is 10 bit and 10 bit video processing is allowed. Continuing to plugins', - }, - }, - -]; - -run(tests); diff --git a/tests/Community/Tdarr_Plugin_00td_filter_bit_depth.js b/tests/Community/Tdarr_Plugin_00td_filter_bit_depth.js new file mode 100644 index 0000000..c3a2bd3 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_00td_filter_bit_depth.js @@ -0,0 +1,242 @@ +/* eslint max-len: 0 */ +const _ = require('lodash'); +const run = require('../helpers/run'); + +const tests = [ + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH265_1.json')), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + processFile: true, infoLog: 'File video is 8 bit. 8 bit is allowed, will process.', + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH265_1.json')), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 8 bit. 8 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '8'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 8 bit. 8 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '8'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: true, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 8 bit. 8 bit is allowed, will process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 10'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 10 bit. 10 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 10'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: true, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 10 bit. 10 bit is allowed, will process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '10'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 10 bit. 10 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '10'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: true, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 10 bit. 10 bit is allowed, will process.', + }, + }, + // + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 12'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 12 bit. 12 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = 'Main 12'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: true, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 12 bit. 12 bit is allowed, will process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '12'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: false, + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'File video is 12 bit. 12 bit is not allowed, will not process.', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH265_1.json')); + file.ffProbeData.streams[0].profile = ''; + file.ffProbeData.streams[0].bits_per_raw_sample = '12'; + return file; + })(), + librarySettings: {}, + inputs: { + process8BitVideo: false, + process10BitVideo: false, + process12BitVideo: true, + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File video is 12 bit. 12 bit is allowed, will process.', + }, + }, +]; + +run(tests); From 3ad6535c6d304a31d6f670b81ea8d9dcae9671f0 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sun, 28 Aug 2022 03:56:02 +0100 Subject: [PATCH 3/3] Update Tdarr_Plugin_00td_filter_bit_depth.js --- Community/Tdarr_Plugin_00td_filter_bit_depth.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Community/Tdarr_Plugin_00td_filter_bit_depth.js b/Community/Tdarr_Plugin_00td_filter_bit_depth.js index 07921e5..b479a0f 100644 --- a/Community/Tdarr_Plugin_00td_filter_bit_depth.js +++ b/Community/Tdarr_Plugin_00td_filter_bit_depth.js @@ -60,6 +60,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { infoLog: '', }; + // process8BitVideo + // process10BitVideo + // process12BitVideo + const bitDepths = { 8: 'Main', 10: 'Main 10',