mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Update flows
This commit is contained in:
parent
658857fdf4
commit
25c4fab8d9
73 changed files with 4295 additions and 839 deletions
|
|
@ -0,0 +1,139 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Run Classic Filter Plugin',
|
||||
description: 'Run one of Tdarr\'s classic plugins that has Operation: Filter',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
name: 'pluginSourceId',
|
||||
type: 'string',
|
||||
defaultValue: 'Community:Tdarr_Plugin_00td_filter_by_codec',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [],
|
||||
},
|
||||
tooltip: 'Specify the classic plugin ID',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File met conditions, would traditionally continue to next plugin in plugin stack',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File did not meet conditions, would traditionally break out of plugin stack',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var path, lib, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, res, container, cacheFilePath, otherArguments, result, outputNumber;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
path = require('path');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
pluginSourceId = String(args.inputs.pluginSourceId);
|
||||
parts = pluginSourceId.split(':');
|
||||
pluginSource = parts[0];
|
||||
pluginId = parts[1];
|
||||
relativePluginPath = "../../../../../".concat(pluginSource, "/").concat(pluginId, ".js");
|
||||
absolutePath = path.resolve(__dirname, relativePluginPath);
|
||||
if (!(pluginSource === 'Community')) return [3 /*break*/, 1];
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
return [3 /*break*/, 3];
|
||||
case 1: return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
plugin: {
|
||||
id: pluginId,
|
||||
source: pluginSource,
|
||||
},
|
||||
})];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
classicPlugin = args.deps.requireFromString(res.pluginRaw, absolutePath);
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
if (classicPlugin.details().Operation !== 'Filter') {
|
||||
throw new Error("".concat('This plugin is meant for classic plugins that have '
|
||||
+ 'Operation: Filter. This classic plugin has Operation: ').concat(classicPlugin.details().Operation)
|
||||
+ 'Please use the Run Classic Transcode Flow Plugin plugin instead.');
|
||||
}
|
||||
container = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
cacheFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(container);
|
||||
otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
ffmpegPath: args.ffmpegPath,
|
||||
mkvpropeditPath: args.mkvpropeditPath,
|
||||
originalLibraryFile: args.originalLibraryFile,
|
||||
nodeHardwareType: args.nodeHardwareType,
|
||||
pluginCycle: 0,
|
||||
workerType: args.workerType,
|
||||
version: args.config.version,
|
||||
platform_arch_isdocker: args.platform_arch_isdocker,
|
||||
cacheFilePath: cacheFilePath,
|
||||
job: args.job,
|
||||
};
|
||||
return [4 /*yield*/, classicPlugin.plugin(args.inputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||
case 4:
|
||||
result = _a.sent();
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
outputNumber = result.processFile ? 1 : 2;
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: outputNumber,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var cliUtils_1 = require("../../../../FlowHelpers/1.0.0/cliUtils");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Run Classic Transcode Plugin',
|
||||
description: 'Run one of Tdarr\'s classic plugins that has Operation: Transcode',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [
|
||||
{
|
||||
name: 'pluginSourceId',
|
||||
type: 'string',
|
||||
defaultValue: 'Community:Tdarr_Plugin_MC93_Migz1FFMPEG',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [],
|
||||
},
|
||||
tooltip: 'Specify the classic plugin ID',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'Continue to next plugin',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var replaceContainer = function (filePath, container) {
|
||||
var parts = filePath.split('.');
|
||||
parts[parts.length - 1] = container.split('.').join('');
|
||||
return parts.join('.');
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var path, lib, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, res_1, container, cacheFilePath, otherArguments, result, cliPath_1, customArgs, isCustomConfig, presetSplit, workerCommand, cliPath, cli, res;
|
||||
var _a, _b, _c;
|
||||
return __generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
case 0:
|
||||
path = require('path');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
pluginSourceId = String(args.inputs.pluginSourceId);
|
||||
parts = pluginSourceId.split(':');
|
||||
pluginSource = parts[0];
|
||||
pluginId = parts[1];
|
||||
relativePluginPath = "../../../../../".concat(pluginSource, "/").concat(pluginId, ".js");
|
||||
absolutePath = path.resolve(__dirname, relativePluginPath);
|
||||
if (!(pluginSource === 'Community')) return [3 /*break*/, 1];
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
return [3 /*break*/, 3];
|
||||
case 1: return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
plugin: {
|
||||
id: pluginId,
|
||||
source: pluginSource,
|
||||
},
|
||||
})];
|
||||
case 2:
|
||||
res_1 = _d.sent();
|
||||
classicPlugin = args.deps.requireFromString(res_1.pluginRaw, absolutePath);
|
||||
_d.label = 3;
|
||||
case 3:
|
||||
if (classicPlugin.details().Operation === 'Filter') {
|
||||
throw new Error("".concat('This plugin is meant for classic plugins that have '
|
||||
+ 'Operation: Transcode. This classic plugin has Operation: ').concat(classicPlugin.details().Operation)
|
||||
+ 'Please use the Run Classic Filter Flow Plugin plugin instead.');
|
||||
}
|
||||
container = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
cacheFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(container);
|
||||
otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
ffmpegPath: args.ffmpegPath,
|
||||
mkvpropeditPath: args.mkvpropeditPath,
|
||||
originalLibraryFile: args.originalLibraryFile,
|
||||
nodeHardwareType: args.nodeHardwareType,
|
||||
pluginCycle: 0,
|
||||
workerType: args.workerType,
|
||||
version: args.config.version,
|
||||
platform_arch_isdocker: args.platform_arch_isdocker,
|
||||
cacheFilePath: cacheFilePath,
|
||||
job: args.job,
|
||||
};
|
||||
return [4 /*yield*/, classicPlugin.plugin(args.inputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||
case 4:
|
||||
result = _d.sent();
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
// --- Backwards compatibility------------
|
||||
if (result.handBrakeMode) {
|
||||
result.handbrakeMode = result.handBrakeMode;
|
||||
}
|
||||
if (result.FFmpegMode) {
|
||||
result.ffmpegMode = result.FFmpegMode;
|
||||
}
|
||||
//----------------------------------------
|
||||
if (result.ffmpegMode) {
|
||||
result.cliToUse = 'ffmpeg';
|
||||
}
|
||||
else if (result.handbrakeMode) {
|
||||
result.cliToUse = 'handbrake';
|
||||
}
|
||||
else if (typeof ((_a = result === null || result === void 0 ? void 0 : result.custom) === null || _a === void 0 ? void 0 : _a.cliPath) === 'string') {
|
||||
cliPath_1 = result.custom.cliPath;
|
||||
if (cliPath_1.toLowerCase().includes('ffmpeg')) {
|
||||
result.cliToUse = 'ffmpeg';
|
||||
}
|
||||
else if (cliPath_1.toLowerCase().includes('handbrake')) {
|
||||
result.cliToUse = 'handbrake';
|
||||
}
|
||||
else if (cliPath_1.toLowerCase().includes('editready')) {
|
||||
result.cliToUse = 'editready';
|
||||
}
|
||||
else if (cliPath_1.toLowerCase().includes('av1an')) {
|
||||
result.cliToUse = 'av1an';
|
||||
}
|
||||
}
|
||||
result.workerLog = result.transcodeSettingsLog;
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
if (result.error) {
|
||||
throw new Error("Plugin ".concat(absolutePath, " failed: ").concat(result.error));
|
||||
}
|
||||
if (result.processFile !== true) {
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
customArgs = (_b = result === null || result === void 0 ? void 0 : result.custom) === null || _b === void 0 ? void 0 : _b.args;
|
||||
isCustomConfig = (Array.isArray(customArgs) && customArgs.length > 0)
|
||||
|| (typeof customArgs === 'string' && customArgs.length > 0);
|
||||
if (!isCustomConfig) {
|
||||
cacheFilePath = replaceContainer(cacheFilePath, result.container);
|
||||
}
|
||||
else {
|
||||
cacheFilePath = result.custom.outputPath;
|
||||
}
|
||||
if (result.preset.includes('<io>')) {
|
||||
presetSplit = result.preset.split('<io>');
|
||||
}
|
||||
else {
|
||||
presetSplit = result.preset.split(',');
|
||||
}
|
||||
workerCommand = [];
|
||||
cliPath = '';
|
||||
if (isCustomConfig) {
|
||||
cliPath = (_c = result === null || result === void 0 ? void 0 : result.custom) === null || _c === void 0 ? void 0 : _c.cliPath;
|
||||
if (Array.isArray(customArgs)) {
|
||||
workerCommand = customArgs;
|
||||
}
|
||||
else {
|
||||
workerCommand = __spreadArray([], args.deps.parseArgsStringToArgv(customArgs, '', ''), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// working on windows with '` and spaces
|
||||
// working on unix with '
|
||||
switch (true) {
|
||||
case result.cliToUse === 'handbrake':
|
||||
workerCommand = __spreadArray([
|
||||
'-i',
|
||||
"".concat(args.inputFileObj._id),
|
||||
'-o',
|
||||
"".concat(cacheFilePath)
|
||||
], args.deps.parseArgsStringToArgv(result.preset, '', ''), true);
|
||||
cliPath = "".concat(args.handbrakePath);
|
||||
break;
|
||||
case result.cliToUse === 'ffmpeg':
|
||||
workerCommand = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], args.deps.parseArgsStringToArgv(presetSplit[0], '', ''), true), [
|
||||
'-i',
|
||||
"".concat(args.inputFileObj._id)
|
||||
], false), args.deps.parseArgsStringToArgv(presetSplit[1], '', ''), true), [
|
||||
"".concat(cacheFilePath),
|
||||
], false);
|
||||
cliPath = "".concat(args.ffmpegPath);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
cli = new cliUtils_1.CLI({
|
||||
cli: cliPath,
|
||||
spawnArgs: workerCommand,
|
||||
spawnOpts: {},
|
||||
jobLog: args.jobLog,
|
||||
outputFilePath: cacheFilePath,
|
||||
inputFileObj: args.inputFileObj,
|
||||
logFullCliOutput: args.logFullCliOutput,
|
||||
updateWorker: args.updateWorker,
|
||||
});
|
||||
return [4 /*yield*/, cli.runCli()];
|
||||
case 5:
|
||||
res = _d.sent();
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog("Running ".concat(cliPath, " failed"));
|
||||
throw new Error("Running ".concat(cliPath, " failed"));
|
||||
}
|
||||
args.logOutcome('tSuc');
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: cacheFilePath,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -7,7 +7,6 @@ var details = function () { return ({
|
|||
description: 'Set 10 Bit Video',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
|
|
@ -27,6 +26,12 @@ 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);
|
||||
for (var i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
|
||||
var stream = args.variables.ffmpegCommand.streams[i];
|
||||
if (stream.codec_type === 'video') {
|
||||
stream.outputArgs.push('-pix_fmt:v:{outputTypeIndex}', 'p010le', '-profile:v:{outputTypeIndex}', 'main10');
|
||||
}
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
|
|
@ -35,9 +35,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var utils_1 = require("../../../../FlowHelpers/1.0.0/utils");
|
||||
var cliUtils_1 = require("../../../../FlowHelpers/1.0.0/cliUtils");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Execute',
|
||||
|
|
@ -53,30 +63,40 @@ var details = function () { return ({
|
|||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File is 480p',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File is 576p',
|
||||
tooltip: 'Continue to next plugin',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var getEncoder = function (codec) {
|
||||
switch (codec) {
|
||||
case 'h264':
|
||||
return 'libx264';
|
||||
case 'hevc':
|
||||
return 'libx265';
|
||||
default:
|
||||
return codec;
|
||||
var getOuputStreamIndex = function (streams, stream) {
|
||||
var index = -1;
|
||||
for (var idx = 0; idx < streams.length; idx += 1) {
|
||||
if (!stream.removed) {
|
||||
index += 1;
|
||||
}
|
||||
if (streams[idx].index === stream.index) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
var getOuputStreamTypeIndex = function (streams, stream) {
|
||||
var index = -1;
|
||||
for (var idx = 0; idx < streams.length; idx += 1) {
|
||||
if (!stream.removed && streams[idx].codec_type === stream.codec_type) {
|
||||
index += 1;
|
||||
}
|
||||
if (streams[idx].index === stream.index) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, cliArgs, shouldProcess, outputFilePath, cli, res;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
var lib, cliArgs, inputArgs, _a, shouldProcess, streams, _loop_1, i, idx, outputFilePath, cli, res;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
|
|
@ -85,23 +105,42 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
cliArgs.push('-y');
|
||||
cliArgs.push('-i');
|
||||
cliArgs.push(args.inputFileObj._id);
|
||||
shouldProcess = false;
|
||||
// @ts-expect-error type
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
if (!stream.removed) {
|
||||
cliArgs.push('-map');
|
||||
cliArgs.push("0:".concat(stream.index));
|
||||
cliArgs.push("-c:".concat(stream.index));
|
||||
args.jobLog(JSON.stringify({ stream: stream }));
|
||||
if (args.inputs.forceProcess || stream.codec_name !== stream.targetCodec) {
|
||||
shouldProcess = true;
|
||||
cliArgs.push(getEncoder(stream.targetCodec));
|
||||
}
|
||||
else {
|
||||
cliArgs.push('copy');
|
||||
}
|
||||
inputArgs = [];
|
||||
_a = args.variables.ffmpegCommand, shouldProcess = _a.shouldProcess, streams = _a.streams;
|
||||
streams = streams.filter(function (stream) {
|
||||
if (stream.removed) {
|
||||
shouldProcess = true;
|
||||
}
|
||||
return !stream.removed;
|
||||
});
|
||||
if ((0, fileUtils_1.getContainer)(args.inputFileObj._id) !== args.variables.ffmpegCommand.container) {
|
||||
shouldProcess = true;
|
||||
}
|
||||
_loop_1 = function (i) {
|
||||
var stream = streams[i];
|
||||
stream.outputArgs = stream.outputArgs.map(function (arg) {
|
||||
if (arg.includes('{outputIndex}')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
arg = arg.replace('{outputIndex}', String(getOuputStreamIndex(streams, stream)));
|
||||
}
|
||||
if (arg.includes('{outputTypeIndex}')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
arg = arg.replace('{outputTypeIndex}', String(getOuputStreamTypeIndex(streams, stream)));
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
cliArgs.push.apply(cliArgs, stream.mapArgs);
|
||||
if (stream.outputArgs.length === 0) {
|
||||
cliArgs.push("-c:".concat(getOuputStreamIndex(streams, stream)), 'copy');
|
||||
}
|
||||
else {
|
||||
cliArgs.push.apply(cliArgs, stream.outputArgs);
|
||||
}
|
||||
inputArgs.push.apply(inputArgs, stream.inputArgs);
|
||||
};
|
||||
for (i = 0; i < streams.length; i += 1) {
|
||||
_loop_1(i);
|
||||
}
|
||||
if (!shouldProcess) {
|
||||
args.jobLog('No need to process file, already as required');
|
||||
return [2 /*return*/, {
|
||||
|
|
@ -110,16 +149,20 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
outputFilePath = "".concat(args.workDir, "/tempFile.").concat(args.variables.ffmpegCommand.container);
|
||||
idx = cliArgs.indexOf('-i');
|
||||
cliArgs.splice.apply(cliArgs, __spreadArray([idx, 0], inputArgs, false));
|
||||
outputFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(args.variables.ffmpegCommand.container);
|
||||
cliArgs.push(outputFilePath);
|
||||
// @ts-expect-error type
|
||||
args.deps.fsextra.ensureDirSync(args.workDir);
|
||||
args.jobLog('Processing file');
|
||||
args.jobLog(JSON.stringify({
|
||||
cliArgs: cliArgs,
|
||||
outputFilePath: outputFilePath,
|
||||
}));
|
||||
cli = new utils_1.CLI({
|
||||
args.updateWorker({
|
||||
CLIType: args.ffmpegPath,
|
||||
preset: cliArgs.join(' '),
|
||||
});
|
||||
cli = new cliUtils_1.CLI({
|
||||
cli: args.ffmpegPath,
|
||||
spawnArgs: cliArgs,
|
||||
spawnOpts: {},
|
||||
|
|
@ -131,10 +174,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
});
|
||||
return [4 /*yield*/, cli.runCli()];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!args.logFullCliOutput) {
|
||||
args.jobLog(res.errorLogFull.slice(-1000).join(''));
|
||||
}
|
||||
res = _b.sent();
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog('Running FFmpeg failed');
|
||||
throw new Error('FFmpeg failed');
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ 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);
|
||||
// @ts-expect-error type
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'data') {
|
||||
stream.removed = true;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ 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);
|
||||
// @ts-expect-error type
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'subtitle') {
|
||||
stream.removed = true;
|
||||
|
|
|
|||
|
|
@ -3,17 +3,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.plugin = exports.details = void 0;
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Set Video Bitrate',
|
||||
description: 'Set Video Bitrate',
|
||||
name: 'Reorder Streams',
|
||||
description: 'Reorder Streams',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [],
|
||||
inputs: [
|
||||
{
|
||||
name: 'processOrder',
|
||||
type: 'string',
|
||||
defaultValue: 'codecs,channels,languages,streamTypes',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the process order.\nFor example, if 'languages' is first, the streams will be ordered based on that first.\nSo put the most important properties last.\nThe default order is suitable for most people.\n\n \\nExample:\\n\n codecs,channels,languages,streamTypes\n ",
|
||||
},
|
||||
{
|
||||
name: 'languages',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the language tags order, separated by commas. Leave blank to disable.\n \\nExample:\\n\n eng,fre\n ",
|
||||
},
|
||||
{
|
||||
name: 'channels',
|
||||
type: 'string',
|
||||
defaultValue: '7.1,5.1,2,1',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the channels order, separated by commas. Leave blank to disable.\n \n \\nExample:\\n\n 7.1,5.1,2,1",
|
||||
},
|
||||
{
|
||||
name: 'codecs',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the codec order, separated by commas. Leave blank to disable.\n \n \\nExample:\\n\n aac,ac3",
|
||||
},
|
||||
{
|
||||
name: 'streamTypes',
|
||||
type: 'string',
|
||||
defaultValue: 'video,audio,subtitle',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the streamTypes order, separated by commas. Leave blank to disable.\n \\nExample:\\n\n video,audio,subtitle\n ",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -27,6 +72,96 @@ 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 streams = JSON.parse(JSON.stringify(args.variables.ffmpegCommand.streams));
|
||||
var originalStreams = JSON.stringify(streams);
|
||||
streams.forEach(function (stream, index) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
stream.typeIndex = index;
|
||||
});
|
||||
var sortStreams = function (sortType) {
|
||||
var items = sortType.inputs.split(',');
|
||||
items.reverse();
|
||||
for (var i = 0; i < items.length; i += 1) {
|
||||
var matchedStreams = [];
|
||||
for (var j = 0; j < streams.length; j += 1) {
|
||||
if (String(sortType.getValue(streams[j])) === String(items[i])) {
|
||||
if (streams[j].codec_long_name
|
||||
&& (streams[j].codec_long_name.includes('image')
|
||||
|| streams[j].codec_name.includes('png'))) {
|
||||
// do nothing, ffmpeg bug, doesn't move image streams
|
||||
}
|
||||
else {
|
||||
matchedStreams.push(streams[j]);
|
||||
streams.splice(j, 1);
|
||||
j -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
streams = matchedStreams.concat(streams);
|
||||
}
|
||||
};
|
||||
var processOrder = String(args.inputs.processOrder);
|
||||
var _a = args.inputs, languages = _a.languages, codecs = _a.codecs, channels = _a.channels, streamTypes = _a.streamTypes;
|
||||
var sortTypes = {
|
||||
languages: {
|
||||
getValue: function (stream) {
|
||||
var _a;
|
||||
if ((_a = stream === null || stream === void 0 ? void 0 : stream.tags) === null || _a === void 0 ? void 0 : _a.language) {
|
||||
return stream.tags.language;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: languages,
|
||||
},
|
||||
codecs: {
|
||||
getValue: function (stream) {
|
||||
try {
|
||||
return stream.codec_name;
|
||||
}
|
||||
catch (err) {
|
||||
// err
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: codecs,
|
||||
},
|
||||
channels: {
|
||||
getValue: function (stream) {
|
||||
var chanMap = {
|
||||
8: '7.1',
|
||||
6: '5.1',
|
||||
2: '2',
|
||||
1: '1',
|
||||
};
|
||||
if ((stream === null || stream === void 0 ? void 0 : stream.channels) && chanMap[stream.channels]) {
|
||||
return chanMap[stream.channels];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: channels,
|
||||
},
|
||||
streamTypes: {
|
||||
getValue: function (stream) {
|
||||
if (stream.codec_type) {
|
||||
return stream.codec_type;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: streamTypes,
|
||||
},
|
||||
};
|
||||
var processOrderArr = processOrder.split(',');
|
||||
for (var k = 0; k < processOrderArr.length; k += 1) {
|
||||
if (sortTypes[processOrderArr[k]] && sortTypes[processOrderArr[k]].inputs) {
|
||||
sortStreams(sortTypes[processOrderArr[k]]);
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(streams) !== originalStreams) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
args.variables.ffmpegCommand.streams = streams;
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ 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);
|
||||
// @ts-expect-error type
|
||||
args.variables.ffmpegCommand.container = args.inputs.container;
|
||||
args.variables.ffmpegCommand.container = String(args.inputs.container);
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
"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: 'Set Video Resolution',
|
||||
description: 'Change video resolution',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [
|
||||
{
|
||||
name: 'targetResolution',
|
||||
type: 'string',
|
||||
defaultValue: '1080p',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'480p',
|
||||
'720p',
|
||||
'1080p',
|
||||
'1440p',
|
||||
'4KUHD',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'Continue to next plugin',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var getVfScale = function (targetResolution) {
|
||||
switch (targetResolution) {
|
||||
case '480p':
|
||||
return ['-vf', 'scale=720:-2'];
|
||||
case '576p':
|
||||
return ['-vf', 'scale=720:-2'];
|
||||
case '720p':
|
||||
return ['-vf', 'scale=1280:-2'];
|
||||
case '1080p':
|
||||
return ['-vf', 'scale=1920:-2'];
|
||||
case '1440p':
|
||||
return ['-vf', 'scale=2560:-2'];
|
||||
case '4KUHD':
|
||||
return ['-vf', 'scale=3840:-2'];
|
||||
default:
|
||||
return ['-vf', 'scale=1920:-2'];
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) {
|
||||
var _a;
|
||||
var lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
for (var i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
|
||||
var stream = args.variables.ffmpegCommand.streams[i];
|
||||
if (stream.codec_type === 'video') {
|
||||
var targetResolution = String(args.inputs.targetResolution);
|
||||
if (targetResolution !== args.inputFileObj.video_resolution) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
var scaleArgs = getVfScale(targetResolution);
|
||||
(_a = stream.outputArgs).push.apply(_a, scaleArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -1,19 +1,29 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Reorder Streams',
|
||||
description: 'Reorder Streams',
|
||||
name: 'Set Video Bitrate',
|
||||
description: 'Set Video Bitrate',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [],
|
||||
inputs: [
|
||||
{
|
||||
name: 'bitrate',
|
||||
type: 'string',
|
||||
defaultValue: '5000',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify bitrate in kbps',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -27,6 +37,12 @@ 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);
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'video') {
|
||||
var ffType = (0, fileUtils_1.getFfType)(stream.codec_type);
|
||||
stream.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(String(args.inputs.bitrate), "k"));
|
||||
}
|
||||
});
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,44 @@
|
|||
"use strict";
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var hardwareUtils_1 = require("../../../../FlowHelpers/1.0.0/hardwareUtils");
|
||||
/* eslint-disable no-param-reassign */
|
||||
var details = function () { return ({
|
||||
name: 'Set Video Encoder',
|
||||
|
|
@ -15,7 +52,7 @@ var details = function () { return ({
|
|||
icon: '',
|
||||
inputs: [
|
||||
{
|
||||
name: 'targetCodec',
|
||||
name: 'outputCodec',
|
||||
type: 'string',
|
||||
defaultValue: 'hevc',
|
||||
inputUI: {
|
||||
|
|
@ -29,6 +66,61 @@ var details = function () { return ({
|
|||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
{
|
||||
name: 'ffmpegPreset',
|
||||
type: 'string',
|
||||
defaultValue: 'fast',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'veryslow',
|
||||
'slower',
|
||||
'slow',
|
||||
'medium',
|
||||
'fast',
|
||||
'faster',
|
||||
'veryfast',
|
||||
'superfast',
|
||||
'ultrafast',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
{
|
||||
name: 'ffmpegQuality',
|
||||
type: 'number',
|
||||
defaultValue: '25',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
{
|
||||
name: 'hardwareEncoding',
|
||||
type: 'boolean',
|
||||
defaultValue: 'true',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify whether to use hardware encoding if available',
|
||||
},
|
||||
{
|
||||
name: 'hardwareDecoding',
|
||||
type: 'boolean',
|
||||
defaultValue: 'true',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify whether to use hardware decoding if available',
|
||||
},
|
||||
{
|
||||
name: 'forceEncoding',
|
||||
type: 'boolean',
|
||||
|
|
@ -52,22 +144,64 @@ var details = function () { return ({
|
|||
}); };
|
||||
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);
|
||||
// @ts-expect-error type
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'video') {
|
||||
// @ts-expect-error type
|
||||
stream.targetCodec = args.inputs.targetCodec;
|
||||
stream.forceEncoding = args.inputs.forceEncoding;
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, hardwareDecoding, i, stream, targetCodec, ffmpegPreset, ffmpegQuality, forceEncoding, hardwarEncoding, encoderProperties;
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
hardwareDecoding = args.inputs.hardwareDecoding === true;
|
||||
args.variables.ffmpegCommand.hardwareDecoding = hardwareDecoding;
|
||||
i = 0;
|
||||
_c.label = 1;
|
||||
case 1:
|
||||
if (!(i < args.variables.ffmpegCommand.streams.length)) return [3 /*break*/, 4];
|
||||
stream = args.variables.ffmpegCommand.streams[i];
|
||||
if (!(stream.codec_type === 'video')) return [3 /*break*/, 3];
|
||||
targetCodec = String(args.inputs.outputCodec);
|
||||
ffmpegPreset = String(args.inputs.ffmpegPreset);
|
||||
ffmpegQuality = String(args.inputs.ffmpegQuality);
|
||||
forceEncoding = args.inputs.forceEncoding === true;
|
||||
hardwarEncoding = args.inputs.hardwareEncoding === true;
|
||||
if (!(forceEncoding
|
||||
|| stream.codec_name !== targetCodec)) return [3 /*break*/, 3];
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
return [4 /*yield*/, (0, hardwareUtils_1.getEncoder)({
|
||||
targetCodec: targetCodec,
|
||||
hardwareEncoding: hardwarEncoding,
|
||||
args: args,
|
||||
})];
|
||||
case 2:
|
||||
encoderProperties = _c.sent();
|
||||
stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder);
|
||||
if (encoderProperties.isGpu) {
|
||||
stream.outputArgs.push('-qp', ffmpegQuality);
|
||||
}
|
||||
else {
|
||||
stream.outputArgs.push('-crf', ffmpegQuality);
|
||||
}
|
||||
if (ffmpegPreset) {
|
||||
stream.outputArgs.push('-preset', ffmpegPreset);
|
||||
}
|
||||
if (hardwareDecoding) {
|
||||
(_a = stream.inputArgs).push.apply(_a, encoderProperties.inputArgs);
|
||||
}
|
||||
if (encoderProperties.outputArgs) {
|
||||
(_b = stream.outputArgs).push.apply(_b, encoderProperties.outputArgs);
|
||||
}
|
||||
_c.label = 3;
|
||||
case 3:
|
||||
i += 1;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [2 /*return*/, {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
|
|||
|
|
@ -42,8 +42,15 @@ var plugin = function (args) {
|
|||
var container = containerParts[containerParts.length - 1];
|
||||
var ffmpegCommand = {
|
||||
inputFiles: [],
|
||||
streams: JSON.parse(JSON.stringify(args.inputFileObj.ffProbeData.streams)).map(function (stream) { return (__assign(__assign({}, stream), { removed: false, targetCodec: stream.codec_name, args: [] })); }),
|
||||
streams: JSON.parse(JSON.stringify(args.inputFileObj.ffProbeData.streams)).map(function (stream) { return (__assign(__assign({}, stream), { removed: false, mapArgs: [
|
||||
'-map',
|
||||
"0:".concat(stream.index),
|
||||
], inputArgs: [], outputArgs: [] })); }),
|
||||
container: container,
|
||||
hardwareDecoding: false,
|
||||
shouldProcess: false,
|
||||
overallInputArguments: [],
|
||||
overallOuputArguments: [],
|
||||
};
|
||||
args.variables.ffmpegCommand = ffmpegCommand;
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Check File Extension',
|
||||
description: 'Check file extension',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
name: 'extensions',
|
||||
type: 'string',
|
||||
defaultValue: 'mkv,mp4',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'A comma separated list of extensions to check',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File is one of extensions',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File is not one of extensions',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
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 extensions = String(args.inputs.extensions);
|
||||
var extensionArray = extensions.trim().split(',');
|
||||
var extension = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
var extensionMatch = false;
|
||||
if (extensionArray.includes(extension)) {
|
||||
extensionMatch = true;
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: extensionMatch ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
"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: 'Check File Size',
|
||||
description: 'Check size of working file',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
name: 'unit',
|
||||
type: 'string',
|
||||
defaultValue: 'GB',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'B',
|
||||
'KB',
|
||||
'MB',
|
||||
'GB',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the unit to use',
|
||||
},
|
||||
{
|
||||
name: 'greaterThan',
|
||||
type: 'number',
|
||||
defaultValue: '0',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify lower bound',
|
||||
},
|
||||
{
|
||||
name: 'lessThan',
|
||||
type: 'number',
|
||||
defaultValue: '10000',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify upper bound',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File within range',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File not within range',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
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 isWithinRange = false;
|
||||
var greaterThanBytes = Number(args.inputs.greaterThan);
|
||||
var lessThanBytes = Number(args.inputs.lessThan);
|
||||
var fileSizeBytes = args.inputFileObj.file_size * 1000 * 1000;
|
||||
if (args.inputs.unit === 'KB') {
|
||||
greaterThanBytes *= 1000;
|
||||
lessThanBytes *= 1000;
|
||||
}
|
||||
else if (args.inputs.unit === 'MB') {
|
||||
greaterThanBytes *= 1000000;
|
||||
lessThanBytes *= 1000000;
|
||||
}
|
||||
else if (args.inputs.unit === 'GB') {
|
||||
greaterThanBytes *= 1000000000;
|
||||
lessThanBytes *= 1000000000;
|
||||
}
|
||||
if (fileSizeBytes >= greaterThanBytes && fileSizeBytes <= lessThanBytes) {
|
||||
isWithinRange = true;
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: isWithinRange ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
"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: 'Compare File Size',
|
||||
description: 'Compare file size of working file compared to original file',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'Working file is smaller than original file',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'Working file is same size as original file',
|
||||
},
|
||||
{
|
||||
number: 3,
|
||||
tooltip: 'Working file is larger than original file',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
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 outputNumber = 1;
|
||||
if (args.inputFileObj.file_size < args.originalLibraryFile.file_size) {
|
||||
outputNumber = 1;
|
||||
}
|
||||
else if (args.inputFileObj.file_size === args.originalLibraryFile.file_size) {
|
||||
outputNumber = 2;
|
||||
}
|
||||
else if (args.inputFileObj.file_size > args.originalLibraryFile.file_size) {
|
||||
outputNumber = 3;
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: outputNumber,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -1,13 +1,50 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Copy to Directory',
|
||||
description: 'Copy the working file to a directory',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
|
|
@ -15,19 +52,26 @@ var details = function () { return ({
|
|||
icon: 'faArrowRight',
|
||||
inputs: [
|
||||
{
|
||||
name: 'target_codec',
|
||||
name: 'outputDirectory',
|
||||
type: 'string',
|
||||
defaultValue: 'hevc',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify ouput directory',
|
||||
},
|
||||
{
|
||||
name: 'makeWorkingFile',
|
||||
type: 'boolean',
|
||||
defaultValue: 'false',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
options: [
|
||||
'hevc',
|
||||
// 'vp9',
|
||||
'h264',
|
||||
// 'vp8',
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
tooltip: 'Make the copied file the working file',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
|
|
@ -39,14 +83,32 @@ var details = function () { return ({
|
|||
}); };
|
||||
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);
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, originalFileName, newContainer, outputPath, workingFile;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
originalFileName = (0, fileUtils_1.getFileName)(args.originalLibraryFile._id);
|
||||
newContainer = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
outputPath = "".concat(args.inputs.outputDirectory, "/").concat(originalFileName, ".").concat(newContainer);
|
||||
return [4 /*yield*/, fs_1.promises.copyFile(args.inputFileObj._id, outputPath)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
workingFile = args.inputFileObj._id;
|
||||
if (args.inputs.makeWorkingFile) {
|
||||
workingFile = outputPath;
|
||||
}
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: workingFile,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ var details = function () { return ({
|
|||
description: 'Move working file to directory.',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
|
|
|
|||
|
|
@ -1,19 +1,66 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Move To Directory',
|
||||
description: 'Move working file to directory.',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [],
|
||||
inputs: [
|
||||
{
|
||||
name: 'outputDirectory',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify ouput directory',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -23,14 +70,28 @@ var details = function () { return ({
|
|||
}); };
|
||||
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);
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, originalFileName, newContainer, outputPath;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
originalFileName = (0, fileUtils_1.getFileName)(args.originalLibraryFile._id);
|
||||
newContainer = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
outputPath = "".concat(args.inputs.outputDirectory, "/").concat(originalFileName, ".").concat(newContainer);
|
||||
return [4 /*yield*/, fs_1.promises.rename(args.inputFileObj._id, outputPath)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: outputPath,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ exports.plugin = exports.details = void 0;
|
|||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Replace Original File',
|
||||
description: 'Replace the origial file',
|
||||
description: 'Replace the original file',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
},
|
||||
|
|
@ -48,23 +48,7 @@ var details = function () { return ({
|
|||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [
|
||||
{
|
||||
name: 'target_codec',
|
||||
type: 'string',
|
||||
defaultValue: 'hevc',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'hevc',
|
||||
// 'vp9',
|
||||
'h264',
|
||||
// 'vp8',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
"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: 'Set Original File',
|
||||
description: 'Set the working file to the original file',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [],
|
||||
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);
|
||||
return {
|
||||
outputFileObj: {
|
||||
_id: args.originalLibraryFile._id,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.plugin = exports.details = void 0;
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Set Video Scale',
|
||||
description: 'Change video scale',
|
||||
name: 'Unpack File',
|
||||
description: 'Unpack a file',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: 'video',
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
icon: 'faArrowRight',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var cliUtils_1 = require("../../../../FlowHelpers/1.0.0/cliUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'HandBrake Custom Arguments',
|
||||
description: 'HandBrake Custom Arguments',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [
|
||||
{
|
||||
name: 'customArguments',
|
||||
type: 'string',
|
||||
defaultValue: '-Z "Fast 1080p30" --all-subtitles',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify HandBrake arguments',
|
||||
},
|
||||
{
|
||||
name: 'jsonPreset',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Paste a HandBrake JSON preset here. Leave blank to disable.',
|
||||
},
|
||||
{
|
||||
name: 'container',
|
||||
type: 'string',
|
||||
defaultValue: 'mkv',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'mkv',
|
||||
'mp4',
|
||||
'm4v',
|
||||
'avi',
|
||||
'mov',
|
||||
'mpg',
|
||||
'mpeg',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify HandBrake arguments',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'Continue to next plugin',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, customArguments, container, outputFilePath, presetString, cliArgs, presetPath, preset, cli, res;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
customArguments = String(args.inputs.customArguments);
|
||||
container = String(args.inputs.container);
|
||||
outputFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(container);
|
||||
presetString = String(args.inputs.jsonPreset);
|
||||
cliArgs = [
|
||||
'-i',
|
||||
"".concat(args.inputFileObj._id),
|
||||
'-o',
|
||||
"".concat(outputFilePath),
|
||||
];
|
||||
presetPath = "".concat(args.workDir, "/preset.json");
|
||||
if (!(presetString.trim() !== '')) return [3 /*break*/, 2];
|
||||
preset = JSON.parse(presetString);
|
||||
return [4 /*yield*/, fs_1.promises.writeFile(presetPath, JSON.stringify(preset, null, 2))];
|
||||
case 1:
|
||||
_a.sent();
|
||||
cliArgs.push('--preset-import-file');
|
||||
cliArgs.push(presetPath);
|
||||
cliArgs.push('-Z');
|
||||
cliArgs.push(preset.PresetList[0].PresetName);
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
cliArgs.push.apply(cliArgs, args.deps.parseArgsStringToArgv(customArguments, '', ''));
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
args.updateWorker({
|
||||
CLIType: args.handbrakePath,
|
||||
preset: cliArgs.join(' '),
|
||||
});
|
||||
cli = new cliUtils_1.CLI({
|
||||
cli: args.handbrakePath,
|
||||
spawnArgs: cliArgs,
|
||||
spawnOpts: {},
|
||||
jobLog: args.jobLog,
|
||||
outputFilePath: outputFilePath,
|
||||
inputFileObj: args.inputFileObj,
|
||||
logFullCliOutput: args.logFullCliOutput,
|
||||
updateWorker: args.updateWorker,
|
||||
});
|
||||
return [4 /*yield*/, cli.runCli()];
|
||||
case 4:
|
||||
res = _a.sent();
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog('Running HandBrake failed');
|
||||
throw new Error('Running HandBrake failed');
|
||||
}
|
||||
args.logOutcome('tSuc');
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: outputFilePath,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -4,7 +4,7 @@ exports.plugin = exports.details = void 0;
|
|||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Input File',
|
||||
description: 'Transcode a video file using ffmpeg. GPU transcoding will be used if possible.',
|
||||
description: 'Start the flow with an input file',
|
||||
style: {
|
||||
borderColor: 'pink',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
"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: 'Fail Flow',
|
||||
description: 'Force the flow to fail and be move to the error table',
|
||||
style: {
|
||||
borderColor: 'red',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faExclamationTriangle',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
}); };
|
||||
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);
|
||||
throw new Error('Forcing flow to fail!');
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
"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: 'Go To Flow',
|
||||
description: 'Go to a different flow',
|
||||
style: {
|
||||
borderColor: 'red',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
}); };
|
||||
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);
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -37,35 +37,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var cliUtils_1 = require("../../../../FlowHelpers/1.0.0/cliUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Unpack File',
|
||||
description: 'Unpack a file',
|
||||
name: 'Run MKVPropEdit',
|
||||
description: 'Run MKVPropEdit on a file to update metadata which'
|
||||
+ ' FFmpeg doesn\'t typically update such as stream bitrate.',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [
|
||||
{
|
||||
name: 'target_codec',
|
||||
type: 'string',
|
||||
defaultValue: 'hevc',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'hevc',
|
||||
// 'vp9',
|
||||
'h264',
|
||||
// 'vp8',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
],
|
||||
icon: '',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -74,46 +59,38 @@ var details = function () { return ({
|
|||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var getNewPath = function (originalPath, tempPath) {
|
||||
var tempPathParts = tempPath.split('.');
|
||||
var container = tempPathParts[tempPathParts.length - 1];
|
||||
var originalPathParts = originalPath.split('.');
|
||||
originalPathParts[originalPathParts.length - 1] = container;
|
||||
return originalPathParts.join('.');
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var fs, lib, currentPath, newPath, newPathTmp;
|
||||
var lib, cliArgs, cli, res;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
fs = require('fs');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
currentPath = args.inputFileObj._id;
|
||||
newPath = getNewPath(args.originalLibraryFile._id, currentPath);
|
||||
newPathTmp = "".concat(newPath, ".tmp");
|
||||
args.jobLog(JSON.stringify({
|
||||
currentPath: currentPath,
|
||||
newPath: newPath,
|
||||
newPathTmp: newPathTmp,
|
||||
}));
|
||||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
cliArgs = [
|
||||
'--add-track-statistics-tags',
|
||||
args.inputFileObj._id,
|
||||
];
|
||||
cli = new cliUtils_1.CLI({
|
||||
cli: args.mkvpropeditPath,
|
||||
spawnArgs: cliArgs,
|
||||
spawnOpts: {},
|
||||
jobLog: args.jobLog,
|
||||
outputFilePath: '',
|
||||
inputFileObj: args.inputFileObj,
|
||||
logFullCliOutput: args.logFullCliOutput,
|
||||
updateWorker: args.updateWorker,
|
||||
});
|
||||
return [4 /*yield*/, cli.runCli()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
fs.renameSync(currentPath, newPathTmp);
|
||||
if (fs.existsSync(newPath)) {
|
||||
fs.unlinkSync(newPath);
|
||||
res = _a.sent();
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog('Running MKVPropEdit failed');
|
||||
throw new Error('Running MKVPropEdit failed');
|
||||
}
|
||||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
case 2:
|
||||
_a.sent();
|
||||
fs.renameSync(newPathTmp, newPath);
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: newPath,
|
||||
},
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
|
|
@ -1,40 +1,4 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
|
|
@ -49,23 +13,7 @@ var details = function () { return ({
|
|||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [
|
||||
{
|
||||
name: 'target_codec',
|
||||
type: 'string',
|
||||
defaultValue: 'hevc',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'hevc',
|
||||
// 'vp9',
|
||||
'h264',
|
||||
// 'vp8',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the codec to use',
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -74,50 +22,15 @@ var details = function () { return ({
|
|||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var getNewPath = function (originalPath, tempPath) {
|
||||
var tempPathParts = tempPath.split('.');
|
||||
var container = tempPathParts[tempPathParts.length - 1];
|
||||
var originalPathParts = originalPath.split('.');
|
||||
originalPathParts[originalPathParts.length - 1] = container;
|
||||
return originalPathParts.join('.');
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var fs, lib, currentPath, newPath, newPathTmp;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
fs = require('fs');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
currentPath = args.inputFileObj._id;
|
||||
newPath = getNewPath(args.originalLibraryFile._id, currentPath);
|
||||
newPathTmp = "".concat(newPath, ".tmp");
|
||||
args.jobLog(JSON.stringify({
|
||||
currentPath: currentPath,
|
||||
newPath: newPath,
|
||||
newPathTmp: newPathTmp,
|
||||
}));
|
||||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
fs.renameSync(currentPath, newPathTmp);
|
||||
if (fs.existsSync(newPath)) {
|
||||
fs.unlinkSync(newPath);
|
||||
}
|
||||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
case 2:
|
||||
_a.sent();
|
||||
fs.renameSync(newPathTmp, newPath);
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: newPath,
|
||||
},
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
}];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
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);
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
"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: 'Check 10 Bit Video',
|
||||
description: 'Check if a file is 10 bit video',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File is 10 bit video',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File is not 10 bit video',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
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 is10Bit = false;
|
||||
for (var i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
|
||||
var stream = args.variables.ffmpegCommand.streams[i];
|
||||
if (stream.codec_type === 'video' && stream.bits_per_raw_sample === 10) {
|
||||
is10Bit = true;
|
||||
}
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: is10Bit ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
"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: 'Check Video Bitrate',
|
||||
description: 'Check if video bitrate is within a specific range',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
name: 'unit',
|
||||
type: 'string',
|
||||
defaultValue: 'kbps',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'bps',
|
||||
'kbps',
|
||||
'mbps',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify the unit to use',
|
||||
},
|
||||
{
|
||||
name: 'greaterThan',
|
||||
type: 'number',
|
||||
defaultValue: '0',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify lower bound',
|
||||
},
|
||||
{
|
||||
name: 'lessThan',
|
||||
type: 'number',
|
||||
defaultValue: '10000',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify upper bound',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File within range',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File not within range',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) {
|
||||
var _a, _b;
|
||||
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 isWithinRange = false;
|
||||
var greaterThanBits = Number(args.inputs.greaterThan);
|
||||
var lessThanBits = Number(args.inputs.lessThan);
|
||||
if (args.inputs.unit === 'kbps') {
|
||||
greaterThanBits *= 1000;
|
||||
lessThanBits *= 1000;
|
||||
}
|
||||
else if (args.inputs.unit === 'mbps') {
|
||||
greaterThanBits *= 1000000;
|
||||
lessThanBits *= 1000000;
|
||||
}
|
||||
if ((_b = (_a = args.inputFileObj) === null || _a === void 0 ? void 0 : _a.mediaInfo) === null || _b === void 0 ? void 0 : _b.track) {
|
||||
args.inputFileObj.mediaInfo.track.forEach(function (stream) {
|
||||
if (stream['@type'] === 'video') {
|
||||
if (stream.BitRate >= greaterThanBits && stream.BitRate <= lessThanBits) {
|
||||
isWithinRange = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: isWithinRange ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -47,12 +47,13 @@ var plugin = function (args) {
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var hasCodec = false;
|
||||
// @ts-expect-error type
|
||||
args.inputFileObj.ffProbeData.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'video' && stream.codec_name === args.inputs.codec) {
|
||||
hasCodec = true;
|
||||
}
|
||||
});
|
||||
if (args.inputFileObj.ffProbeData.streams) {
|
||||
args.inputFileObj.ffProbeData.streams.forEach(function (stream) {
|
||||
if (stream.codec_type === 'video' && stream.codec_name === args.inputs.codec) {
|
||||
hasCodec = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: hasCodec ? 1 : 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue