Merge pull request #443 from HaveAGitGat/2.10.01

2.10.01
make-only-subtitle-default
HaveAGitGat 2 years ago committed by GitHub
commit 25c095a243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,200 @@
"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 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: 'Normalize Audio',
description: 'Normalize Audio',
style: {
borderColor: '#6efefc',
},
tags: 'video',
isStartPlugin: false,
sidebarPosition: -1,
icon: '',
inputs: [
{
name: 'i',
type: 'string',
defaultValue: '-23.0',
inputUI: {
type: 'text',
},
tooltip: "\"i\" value used in loudnorm pass \\n\n defaults to -23.0",
},
{
name: 'lra',
type: 'string',
defaultValue: '7.0',
inputUI: {
type: 'text',
},
tooltip: "Desired lra value. \\n Defaults to 7.0 \n ",
},
{
name: 'tp',
type: 'string',
defaultValue: '-2.0',
inputUI: {
type: 'text',
},
tooltip: "Desired \"tp\" value. \\n Defaults to -2.0 \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) { return __awaiter(void 0, void 0, void 0, function () {
var lib, loudNorm_i, lra, tp, container, outputFilePath, normArgs1, cli, res, lines, idx, parts, infoLine, loudNormValues, normArgs2, cli2, res2;
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);
loudNorm_i = args.inputs.i;
lra = args.inputs.lra;
tp = args.inputs.tp;
container = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
outputFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(container);
normArgs1 = [
'-i',
args.inputFileObj._id,
'-af',
"loudnorm=I=".concat(loudNorm_i, ":LRA=").concat(lra, ":TP=").concat(tp, ":print_format=json"),
'-f',
'null',
'NUL',
'-map',
'0',
'-c',
'copy',
];
cli = new cliUtils_1.CLI({
cli: args.ffmpegPath,
spawnArgs: normArgs1,
spawnOpts: {},
jobLog: args.jobLog,
outputFilePath: '',
inputFileObj: args.inputFileObj,
logFullCliOutput: args.logFullCliOutput,
updateWorker: args.updateWorker,
});
return [4 /*yield*/, cli.runCli()];
case 1:
res = _a.sent();
if (res.cliExitCode !== 0) {
args.jobLog('Running FFmpeg failed');
throw new Error('FFmpeg failed');
}
lines = res.errorLogFull;
idx = -1;
// get last index of Parsed_loudnorm
lines.forEach(function (line, i) {
if (line.includes('Parsed_loudnorm')) {
idx = i;
}
});
if (idx === -1) {
throw new Error('Failed to find loudnorm in report, please rerun');
}
parts = lines[idx].split(']');
parts.shift();
infoLine = parts.join(']');
infoLine = infoLine.split('\r\n').join('').split('\t').join('');
console.log({
infoLine: infoLine,
});
loudNormValues = JSON.parse(infoLine);
args.jobLog("Loudnorm first pass values returned: \n".concat(JSON.stringify(loudNormValues)));
normArgs2 = [
'-i',
args.inputFileObj._id,
'-map',
'0',
'-c',
'copy',
'-c:a',
'aac',
'-b:a',
'192k',
'-af',
"loudnorm=print_format=summary:linear=true:I=".concat(loudNorm_i, ":LRA=").concat(lra, ":TP=").concat(tp, ":")
+ "measured_i=".concat(loudNormValues.input_i, ":")
+ "measured_lra=".concat(loudNormValues.input_lra, ":")
+ "measured_tp=".concat(loudNormValues.input_tp, ":")
+ "measured_thresh=".concat(loudNormValues.input_thresh, ":offset=").concat(loudNormValues.target_offset, " "),
outputFilePath,
];
cli2 = new cliUtils_1.CLI({
cli: args.ffmpegPath,
spawnArgs: normArgs2,
spawnOpts: {},
jobLog: args.jobLog,
outputFilePath: outputFilePath,
inputFileObj: args.inputFileObj,
logFullCliOutput: args.logFullCliOutput,
updateWorker: args.updateWorker,
});
return [4 /*yield*/, cli2.runCli()];
case 2:
res2 = _a.sent();
if (res2.cliExitCode !== 0) {
args.jobLog('Running FFmpeg failed');
throw new Error('FFmpeg failed');
}
return [2 /*return*/, {
outputFileObj: {
_id: outputFilePath,
},
outputNumber: 1,
variables: args.variables,
}];
}
});
}); };
exports.plugin = plugin;

@ -7,7 +7,6 @@ var details = function () { return ({
description: 'Convert HDR to SDR',
style: {
borderColor: '#6efefc',
opacity: 0.5,
},
tags: 'video',
isStartPlugin: false,
@ -27,6 +26,11 @@ 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') {
stream.outputArgs.push('-vf', 'zscale=t=linear:npl=100,format=yuv420p');
}
});
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,

@ -39,6 +39,7 @@ 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");
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'HandBrake Custom Arguments',
@ -76,6 +77,7 @@ var details = function () { return ({
inputUI: {
type: 'dropdown',
options: [
'original',
'mkv',
'mp4',
'm4v',
@ -107,6 +109,9 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
args.inputs = lib.loadDefaultValues(args.inputs, details);
customArguments = String(args.inputs.customArguments);
container = String(args.inputs.container);
if (container === 'original') {
container = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
}
outputFilePath = "".concat(args.workDir, "/tempFile_").concat(new Date().getTime(), ".").concat(container);
presetString = String(args.inputs.jsonPreset);
cliArgs = [

@ -0,0 +1,49 @@
"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 HDR',
description: 'Check if video is HDR',
style: {
borderColor: 'orange',
},
tags: 'video',
isStartPlugin: false,
sidebarPosition: -1,
icon: 'faQuestion',
inputs: [],
outputs: [
{
number: 1,
tooltip: 'File is HDR',
},
{
number: 2,
tooltip: 'File is not HDR',
},
],
}); };
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 isHdr = 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.transfer_characteristics === 'smpte2084'
&& stream.color_primaries === 'bt2020'
&& stream.color_range === 'tv') {
isHdr = true;
}
}
return {
outputFileObj: args.inputFileObj,
outputNumber: isHdr ? 1 : 2,
variables: args.variables,
};
};
exports.plugin = plugin;

@ -0,0 +1,182 @@
import { CLI } from '../../../../FlowHelpers/1.0.0/cliUtils';
import { getContainer } from '../../../../FlowHelpers/1.0.0/fileUtils';
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Normalize Audio',
description: 'Normalize Audio',
style: {
borderColor: '#6efefc',
},
tags: 'video',
isStartPlugin: false,
sidebarPosition: -1,
icon: '',
inputs: [
{
name: 'i',
type: 'string',
defaultValue: '-23.0',
inputUI: {
type: 'text',
},
tooltip: `"i" value used in loudnorm pass \\n
defaults to -23.0`,
},
{
name: 'lra',
type: 'string',
defaultValue: '7.0',
inputUI: {
type: 'text',
},
tooltip: `Desired lra value. \\n Defaults to 7.0
`,
},
{
name: 'tp',
type: 'string',
defaultValue: '-2.0',
inputUI: {
type: 'text',
},
tooltip: `Desired "tp" value. \\n Defaults to -2.0
`,
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = async (args: IpluginInputArgs): Promise<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);
// setup required varibles
const loudNorm_i = args.inputs.i;
const { lra } = args.inputs;
const { tp } = args.inputs;
const container = getContainer(args.inputFileObj._id);
const outputFilePath = `${args.workDir}/tempFile_${new Date().getTime()}.${container}`;
const normArgs1: string[] = [
'-i',
args.inputFileObj._id,
'-af',
`loudnorm=I=${loudNorm_i}:LRA=${lra}:TP=${tp}:print_format=json`,
'-f',
'null',
'NUL',
'-map',
'0',
'-c',
'copy',
];
const cli = new CLI({
cli: args.ffmpegPath,
spawnArgs: normArgs1,
spawnOpts: {},
jobLog: args.jobLog,
outputFilePath: '',
inputFileObj: args.inputFileObj,
logFullCliOutput: args.logFullCliOutput,
updateWorker: args.updateWorker,
});
const res = await cli.runCli();
if (res.cliExitCode !== 0) {
args.jobLog('Running FFmpeg failed');
throw new Error('FFmpeg failed');
}
const lines = res.errorLogFull;
let idx = -1;
// get last index of Parsed_loudnorm
lines.forEach((line, i) => {
if (line.includes('Parsed_loudnorm')) {
idx = i;
}
});
if (idx === -1) {
throw new Error('Failed to find loudnorm in report, please rerun');
}
const parts = lines[idx].split(']');
parts.shift();
let infoLine = parts.join(']');
infoLine = infoLine.split('\r\n').join('').split('\t').join('');
console.log({
infoLine,
});
const loudNormValues = JSON.parse(infoLine);
args.jobLog(`Loudnorm first pass values returned: \n${JSON.stringify(loudNormValues)}`);
const normArgs2 = [
'-i',
args.inputFileObj._id,
'-map',
'0',
'-c',
'copy',
'-c:a',
'aac',
'-b:a',
'192k',
'-af',
`loudnorm=print_format=summary:linear=true:I=${loudNorm_i}:LRA=${lra}:TP=${tp}:`
+ `measured_i=${loudNormValues.input_i}:`
+ `measured_lra=${loudNormValues.input_lra}:`
+ `measured_tp=${loudNormValues.input_tp}:`
+ `measured_thresh=${loudNormValues.input_thresh}:offset=${loudNormValues.target_offset} `,
outputFilePath,
];
const cli2 = new CLI({
cli: args.ffmpegPath,
spawnArgs: normArgs2,
spawnOpts: {},
jobLog: args.jobLog,
outputFilePath,
inputFileObj: args.inputFileObj,
logFullCliOutput: args.logFullCliOutput,
updateWorker: args.updateWorker,
});
const res2 = await cli2.runCli();
if (res2.cliExitCode !== 0) {
args.jobLog('Running FFmpeg failed');
throw new Error('FFmpeg failed');
}
return {
outputFileObj: {
_id: outputFilePath,
},
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};

@ -5,7 +5,6 @@ import {
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
import { CLI } from '../../../../FlowHelpers/1.0.0/cliUtils';
import { getContainer } from '../../../../FlowHelpers/1.0.0/fileUtils';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({

@ -10,7 +10,6 @@ const details = () :IpluginDetails => ({
description: 'Convert HDR to SDR',
style: {
borderColor: '#6efefc',
opacity: 0.5,
},
tags: 'video',
isStartPlugin: false,
@ -31,6 +30,12 @@ const plugin = (args:IpluginInputArgs):IpluginOutputArgs => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
args.variables.ffmpegCommand.streams.forEach((stream) => {
if (stream.codec_type === 'video') {
stream.outputArgs.push('-vf', 'zscale=t=linear:npl=100,format=yuv420p');
}
});
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,

@ -5,6 +5,7 @@ import {
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
import { getContainer } from '../../../../FlowHelpers/1.0.0/fileUtils';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = ():IpluginDetails => ({
@ -43,6 +44,7 @@ const details = ():IpluginDetails => ({
inputUI: {
type: 'dropdown',
options: [
'original',
'mkv',
'mp4',
'm4v',
@ -70,7 +72,12 @@ const plugin = async (args:IpluginInputArgs):Promise<IpluginOutputArgs> => {
args.inputs = lib.loadDefaultValues(args.inputs, details);
const customArguments = String(args.inputs.customArguments);
const container = String(args.inputs.container);
let container = String(args.inputs.container);
if (container === 'original') {
container = getContainer(args.inputFileObj._id);
}
const outputFilePath = `${args.workDir}/tempFile_${new Date().getTime()}.${container}`;

@ -0,0 +1,60 @@
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Check HDR',
description: 'Check if video is HDR',
style: {
borderColor: 'orange',
},
tags: 'video',
isStartPlugin: false,
sidebarPosition: -1,
icon: 'faQuestion',
inputs: [],
outputs: [
{
number: 1,
tooltip: 'File is HDR',
},
{
number: 2,
tooltip: 'File is not HDR',
},
],
});
// 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);
let isHdr = false;
for (let i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
const stream = args.variables.ffmpegCommand.streams[i];
if (
stream.codec_type === 'video'
&& stream.transfer_characteristics === 'smpte2084'
&& stream.color_primaries === 'bt2020'
&& stream.color_range === 'tv'
) {
isHdr = true;
}
}
return {
outputFileObj: args.inputFileObj,
outputNumber: isHdr ? 1 : 2,
variables: args.variables,
};
};
export {
details,
plugin,
};

58
package-lock.json generated

@ -19,6 +19,7 @@
"@typescript-eslint/parser": "^4.14.1",
"chai": "^4.3.6",
"eslint": "^7.14.0",
"eslint_d": "^11.1.1",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
@ -691,6 +692,39 @@
"node": ">=0.10.0"
}
},
"node_modules/core_d": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/core_d/-/core_d-3.2.0.tgz",
"integrity": "sha512-waKkgHU2P19huhuMjCqCDWTYjxCIHoB+nnYjI7pVMUOC1giWxMNDrXkPw9QjWY+PWCFm49bD3wA/J+c7BGZ+og==",
"dev": true,
"dependencies": {
"supports-color": "^8.1.0"
}
},
"node_modules/core_d/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/core_d/node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/core-js-pure": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.8.1.tgz",
@ -936,6 +970,21 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint_d": {
"version": "11.1.1",
"resolved": "https://registry.npmjs.org/eslint_d/-/eslint_d-11.1.1.tgz",
"integrity": "sha512-PaNWblwIa10KZUt9EObGBzrsaxB+CPtk5d99sTveXmAtQrPSmrntKpWqxN/Mwot0qnI5gCllzkPZi6tO710KUA==",
"dev": true,
"dependencies": {
"core_d": "^3.2.0",
"eslint": "^7.3.0",
"nanolru": "^1.0.0",
"optionator": "^0.9.1"
},
"bin": {
"eslint_d": "bin/eslint_d.js"
}
},
"node_modules/eslint-config-airbnb-base": {
"version": "14.2.1",
"resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz",
@ -1954,6 +2003,15 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/nanolru": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/nanolru/-/nanolru-1.0.0.tgz",
"integrity": "sha512-GyQkE8M32pULhQk7Sko5raoIbPalAk90ICG+An4fq6fCsFHsP6fB2K46WGXVdoJpy4SGMnZ/EKbo123fZJomWg==",
"dev": true,
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",

@ -17,12 +17,13 @@
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prefer-arrow-functions": "^3.1.4"
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
"eslint_d": "^11.1.1"
},
"scripts": {
"test": "node ./tests/runTests.js",
"lint": "eslint FlowPluginsTs Community methods examples tests --ext js,ts",
"lint:fix": "eslint FlowPluginsTs Community methods examples tests --ext js,ts --fix",
"lint": "eslint_d FlowPluginsTs Community methods examples tests --ext js,ts",
"lint:fix": "eslint_d FlowPluginsTs Community methods examples tests --ext js,ts --fix",
"checkPlugins": "node ./tests/checkPlugins.js"
},
"repository": {

Loading…
Cancel
Save