parent
df9195c0d7
commit
3b251fc4b7
@ -0,0 +1,104 @@
|
||||
const details = () => ({
|
||||
id: 'Tdarr_Plugin_00td_action_remove_stream_by_specified_property',
|
||||
Stage: 'Pre-processing',
|
||||
Name: 'Remove streams specified property',
|
||||
Type: 'Video',
|
||||
Operation: 'Transcode',
|
||||
Description: `
|
||||
This plugin removes streams based on the specified property.
|
||||
`,
|
||||
Version: '1.00',
|
||||
Tags: 'action',
|
||||
Inputs: [
|
||||
{
|
||||
name: 'propertyToCheck',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip:
|
||||
`Enter one stream property to check.
|
||||
|
||||
\\nExample:\\n
|
||||
codec_name
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: 'valuesToRemove',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip:
|
||||
`Enter values of the property above to remove. For example, if removing by codec_name, could enter ac3,aac:
|
||||
|
||||
\\nExample:\\n
|
||||
ac3,aac
|
||||
`,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 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,
|
||||
preset: '',
|
||||
container: `.${file.container}`,
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: '',
|
||||
};
|
||||
|
||||
if (inputs.propertyToCheck.trim() === '') {
|
||||
response.infoLog += 'No input propertyToCheck entered in plugin, skipping \n';
|
||||
return response;
|
||||
}
|
||||
|
||||
const propertyToCheck = inputs.propertyToCheck.trim();
|
||||
|
||||
if (inputs.valuesToRemove.trim() === '') {
|
||||
response.infoLog += 'No input valuesToRemove entered in plugin, skipping \n';
|
||||
return response;
|
||||
}
|
||||
|
||||
const valuesToRemove = inputs.valuesToRemove.trim().split(',');
|
||||
|
||||
response.preset += ', -map 0 -c copy -max_muxing_queue_size 9999';
|
||||
|
||||
try {
|
||||
let streamToRemove = false;
|
||||
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||
try {
|
||||
if (valuesToRemove.includes(file.ffProbeData.streams[i][propertyToCheck])) {
|
||||
response.preset += ` -map -0:${i} `;
|
||||
response.infoLog += ` Removing stream ${i} which is has ${propertyToCheck}`
|
||||
+ ` of ${file.ffProbeData.streams[i][propertyToCheck]} \n`;
|
||||
streamToRemove = true;
|
||||
}
|
||||
} catch (err) {
|
||||
response.infoLog += ` Error reading stream ${i} ${propertyToCheck} \n`;
|
||||
}
|
||||
}
|
||||
|
||||
if (streamToRemove === true) {
|
||||
response.processFile = true;
|
||||
response.infoLog += ' Files has streams which need to be removed, processing \n';
|
||||
} else {
|
||||
response.infoLog += ' Files does not have streams which need to be removed \n';
|
||||
}
|
||||
} catch (err) {
|
||||
response.infoLog += ` Error checking streams:${err}`;
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
module.exports.details = details;
|
||||
module.exports.plugin = plugin;
|
||||
@ -0,0 +1,201 @@
|
||||
/* eslint max-len: 0 */
|
||||
const _ = require('lodash');
|
||||
const run = require('../helpers/run');
|
||||
|
||||
const tests = [
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: false,
|
||||
preset: '',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: 'No input propertyToCheck entered in plugin, skipping \n',
|
||||
},
|
||||
},
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: '',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: false,
|
||||
preset: '',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: 'No input propertyToCheck entered in plugin, skipping \n',
|
||||
},
|
||||
},
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_tag',
|
||||
valuesToRemove: '',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: false,
|
||||
preset: '',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: 'No input valuesToRemove entered in plugin, skipping \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_tag',
|
||||
valuesToRemove: '0x31637661',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: true,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999 -map -0:0 ',
|
||||
container: '.mp4',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Removing stream 0 which is has codec_tag of 0x31637661 \n'
|
||||
+ ' Files has streams which need to be removed, processing \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_tag',
|
||||
valuesToRemove: '0x31637661,0x6134706d',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: true,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999 -map -0:0 -map -0:1 ',
|
||||
container: '.mp4',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Removing stream 0 which is has codec_tag of 0x31637661 \n'
|
||||
+ ' Removing stream 1 which is has codec_tag of 0x6134706d \n'
|
||||
+ ' Files has streams which need to be removed, processing \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_tag',
|
||||
valuesToRemove: 'random',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: false,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Files does not have streams which need to be removed \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_type',
|
||||
valuesToRemove: 'video',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: true,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999 -map -0:0 ',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Removing stream 0 which is has codec_type of video \n'
|
||||
+ ' Files has streams which need to be removed, processing \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_type',
|
||||
valuesToRemove: 'video,audio',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: true,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999 -map -0:0 -map -0:1 -map -0:2 -map -0:3 -map -0:4 -map -0:5 ',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Removing stream 0 which is has codec_type of video \n'
|
||||
+ ' Removing stream 1 which is has codec_type of audio \n'
|
||||
+ ' Removing stream 2 which is has codec_type of audio \n'
|
||||
+ ' Removing stream 3 which is has codec_type of audio \n'
|
||||
+ ' Removing stream 4 which is has codec_type of audio \n'
|
||||
+ ' Removing stream 5 which is has codec_type of audio \n'
|
||||
+ ' Files has streams which need to be removed, processing \n',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
input: {
|
||||
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||
librarySettings: {},
|
||||
inputs: {
|
||||
propertyToCheck: 'codec_type',
|
||||
valuesToRemove: 'random',
|
||||
},
|
||||
otherArguments: {},
|
||||
},
|
||||
output: {
|
||||
processFile: false,
|
||||
preset: ', -map 0 -c copy -max_muxing_queue_size 9999',
|
||||
container: '.mkv',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: false,
|
||||
infoLog: ' Files does not have streams which need to be removed \n',
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
run(tests);
|
||||
Loading…
Reference in new issue