-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from HaveAGitGat/Remove-Stream-By-Property
Add Remove Stream By Property
- Loading branch information
Showing
2 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...ins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandRemoveStreamByProperty/1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.plugin = exports.details = void 0; | ||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ | ||
var details = function () { return ({ | ||
name: 'Remove Stream By Property', | ||
description: 'Remove Stream By Property', | ||
style: { | ||
borderColor: '#6efefc', | ||
}, | ||
tags: 'video', | ||
isStartPlugin: false, | ||
pType: '', | ||
requiresVersion: '2.11.01', | ||
sidebarPosition: -1, | ||
icon: '', | ||
inputs: [ | ||
{ | ||
name: 'propertyToCheck', | ||
type: 'string', | ||
defaultValue: 'codec_name', | ||
inputUI: { | ||
type: 'text', | ||
}, | ||
tooltip: "\n Enter one stream property to check.\n \n \\nExample:\\n\n codec_name\n\n \\nExample:\\n\n tags.language\n ", | ||
}, | ||
{ | ||
name: 'valuesToRemove', | ||
type: 'string', | ||
defaultValue: 'aac', | ||
inputUI: { | ||
type: 'text', | ||
}, | ||
tooltip: "\n Enter values of the property above to remove. For example, if removing by codec_name, could enter ac3,aac:\n \n \\nExample:\\n\n ac3,aac\n ", | ||
}, | ||
{ | ||
name: 'condition', | ||
type: 'string', | ||
defaultValue: 'includes', | ||
inputUI: { | ||
type: 'dropdown', | ||
options: [ | ||
'includes', | ||
'not_includes', | ||
], | ||
}, | ||
tooltip: "\n Specify whether to remove streams that include or do not include the values above.\n ", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
number: 1, | ||
tooltip: 'Continue to next plugin', | ||
}, | ||
], | ||
}); }; | ||
exports.details = details; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
var plugin = function (args) { | ||
var lib = require('../../../../../methods/lib')(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign | ||
args.inputs = lib.loadDefaultValues(args.inputs, details); | ||
var propertyToCheck = String(args.inputs.propertyToCheck).trim(); | ||
var valuesToRemove = String(args.inputs.valuesToRemove).trim().split(','); | ||
var condition = String(args.inputs.condition); | ||
args.variables.ffmpegCommand.streams.forEach(function (stream) { | ||
var _a; | ||
var target = ''; | ||
if (propertyToCheck.includes('.')) { | ||
var parts = propertyToCheck.split('.'); | ||
target = (_a = stream[parts[0]]) === null || _a === void 0 ? void 0 : _a[parts[1]]; | ||
} | ||
else { | ||
target = stream[propertyToCheck]; | ||
} | ||
if (target) { | ||
var prop = String(target).toLowerCase(); | ||
for (var i = 0; i < valuesToRemove.length; i += 1) { | ||
var val = valuesToRemove[i].toLowerCase(); | ||
var prefix = "Removing stream index ".concat(stream.index, " because ").concat(propertyToCheck, " of ").concat(prop); | ||
if (condition === 'includes' && prop.includes(val)) { | ||
args.jobLog("".concat(prefix, " includes ").concat(val, "\n")); | ||
// eslint-disable-next-line no-param-reassign | ||
stream.removed = true; | ||
} | ||
else if (condition === 'not_includes' && !prop.includes(val)) { | ||
args.jobLog("".concat(prefix, " not_includes ").concat(val, "\n")); | ||
// eslint-disable-next-line no-param-reassign | ||
stream.removed = true; | ||
} | ||
} | ||
} | ||
}); | ||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber: 1, | ||
variables: args.variables, | ||
}; | ||
}; | ||
exports.plugin = plugin; |
125 changes: 125 additions & 0 deletions
125
...sTs/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandRemoveStreamByProperty/1.0.0/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { | ||
IpluginDetails, | ||
IpluginInputArgs, | ||
IpluginOutputArgs, | ||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; | ||
|
||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ | ||
const details = (): IpluginDetails => ({ | ||
name: 'Remove Stream By Property', | ||
description: 'Remove Stream By Property', | ||
style: { | ||
borderColor: '#6efefc', | ||
}, | ||
tags: 'video', | ||
isStartPlugin: false, | ||
pType: '', | ||
requiresVersion: '2.11.01', | ||
sidebarPosition: -1, | ||
icon: '', | ||
inputs: [ | ||
{ | ||
name: 'propertyToCheck', | ||
type: 'string', | ||
defaultValue: 'codec_name', | ||
inputUI: { | ||
type: 'text', | ||
}, | ||
tooltip: | ||
` | ||
Enter one stream property to check. | ||
\\nExample:\\n | ||
codec_name | ||
\\nExample:\\n | ||
tags.language | ||
`, | ||
}, | ||
{ | ||
name: 'valuesToRemove', | ||
type: 'string', | ||
defaultValue: 'aac', | ||
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 | ||
`, | ||
}, | ||
{ | ||
name: 'condition', | ||
type: 'string', | ||
defaultValue: 'includes', | ||
inputUI: { | ||
type: 'dropdown', | ||
options: [ | ||
'includes', | ||
'not_includes', | ||
], | ||
}, | ||
tooltip: ` | ||
Specify whether to remove streams that include or do not include the values above. | ||
`, | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
number: 1, | ||
tooltip: 'Continue to next plugin', | ||
}, | ||
], | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { | ||
const lib = require('../../../../../methods/lib')(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign | ||
args.inputs = lib.loadDefaultValues(args.inputs, details); | ||
|
||
const propertyToCheck = String(args.inputs.propertyToCheck).trim(); | ||
const valuesToRemove = String(args.inputs.valuesToRemove).trim().split(','); | ||
const condition = String(args.inputs.condition); | ||
|
||
args.variables.ffmpegCommand.streams.forEach((stream) => { | ||
let target = ''; | ||
if (propertyToCheck.includes('.')) { | ||
const parts = propertyToCheck.split('.'); | ||
target = stream[parts[0]]?.[parts[1]]; | ||
} else { | ||
target = stream[propertyToCheck]; | ||
} | ||
|
||
if (target) { | ||
const prop = String(target).toLowerCase(); | ||
for (let i = 0; i < valuesToRemove.length; i += 1) { | ||
const val = valuesToRemove[i].toLowerCase(); | ||
|
||
const prefix = `Removing stream index ${stream.index} because ${propertyToCheck} of ${prop}`; | ||
if (condition === 'includes' && prop.includes(val)) { | ||
args.jobLog(`${prefix} includes ${val}\n`); | ||
// eslint-disable-next-line no-param-reassign | ||
stream.removed = true; | ||
} else if (condition === 'not_includes' && !prop.includes(val)) { | ||
args.jobLog(`${prefix} not_includes ${val}\n`); | ||
// eslint-disable-next-line no-param-reassign | ||
stream.removed = true; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber: 1, | ||
variables: args.variables, | ||
}; | ||
}; | ||
export { | ||
details, | ||
plugin, | ||
}; |