From 57b4662c3d86c3d0235aeb1a2c15fece50cf3f42 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sat, 1 Jun 2024 06:41:09 +0100 Subject: [PATCH 1/2] Update worker with hb fps if available --- FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts | 23 +++++++++++++++++++ FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts | 14 ++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts b/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts index 4c9bded30..1429e744e 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts @@ -39,6 +39,28 @@ const handbrakeParser = ({ return percentage; }; +const getHandBrakeFps = ({ + str, +}: { + str: string, +}): number => { + try { + if (typeof str !== 'string' || !(str.includes('(') && str.includes('fps'))) { + return 0; + } + + const out = parseInt(str.split('(')[1].split('fps')[0].trim(), 10); + + // eslint-disable-next-line no-restricted-globals + if (!isNaN(out)) { + return out; + } + } catch (err) { + // err + } + return 0; +}; + // frame= 889 fps=106 q=26.0 Lsize= 25526kB time=00:00:35.69 bitrate=5858.3kbits/s speed=4.25x const getFFmpegVar = ({ str, @@ -227,5 +249,6 @@ export { ffmpegParser, getFFmpegPercentage, getFFmpegVar, + getHandBrakeFps, editreadyParser, }; diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts index 6da999cc8..4bb36cbf7 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts @@ -1,4 +1,6 @@ -import { editreadyParser, ffmpegParser, handbrakeParser } from './cliParsers'; +import { + editreadyParser, ffmpegParser, getHandBrakeFps, handbrakeParser, +} from './cliParsers'; import { Ilog, IupdateWorker } from './interfaces/interfaces'; import { IFileObject, Istreams } from './interfaces/synced/IFileObject'; @@ -182,6 +184,16 @@ class CLI { percentage, }); } + + const fps = getHandBrakeFps({ + str, + }); + + if (fps > 0) { + this.config.updateWorker({ + fps, + }); + } } else if (this.config.cli.toLowerCase().includes('ffmpeg')) { const n = str.indexOf('fps'); const shouldUpdate = str.length >= 6 && n >= 6; From 808e43e2b552f9a75c8ec3b6385a4b66bf1f256a Mon Sep 17 00:00:00 2001 From: HaveAGitGat Date: Sat, 1 Jun 2024 05:43:11 +0000 Subject: [PATCH 2/2] Apply auto-build changes --- FlowPlugins/FlowHelpers/1.0.0/cliParsers.js | 20 +++++++++++++++++++- FlowPlugins/FlowHelpers/1.0.0/cliUtils.js | 8 ++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/FlowPlugins/FlowHelpers/1.0.0/cliParsers.js b/FlowPlugins/FlowHelpers/1.0.0/cliParsers.js index eee0cfde1..e14129012 100644 --- a/FlowPlugins/FlowHelpers/1.0.0/cliParsers.js +++ b/FlowPlugins/FlowHelpers/1.0.0/cliParsers.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.editreadyParser = exports.getFFmpegVar = exports.getFFmpegPercentage = exports.ffmpegParser = exports.handbrakeParser = void 0; +exports.editreadyParser = exports.getHandBrakeFps = exports.getFFmpegVar = exports.getFFmpegPercentage = exports.ffmpegParser = exports.handbrakeParser = void 0; var handbrakeParser = function (_a) { var str = _a.str, hbPass = _a.hbPass; if (typeof str !== 'string') { @@ -30,6 +30,24 @@ var handbrakeParser = function (_a) { return percentage; }; exports.handbrakeParser = handbrakeParser; +var getHandBrakeFps = function (_a) { + var str = _a.str; + try { + if (typeof str !== 'string' || !(str.includes('(') && str.includes('fps'))) { + return 0; + } + var out = parseInt(str.split('(')[1].split('fps')[0].trim(), 10); + // eslint-disable-next-line no-restricted-globals + if (!isNaN(out)) { + return out; + } + } + catch (err) { + // err + } + return 0; +}; +exports.getHandBrakeFps = getHandBrakeFps; // frame= 889 fps=106 q=26.0 Lsize= 25526kB time=00:00:35.69 bitrate=5858.3kbits/s speed=4.25x var getFFmpegVar = function (_a) { var str = _a.str, variable = _a.variable; diff --git a/FlowPlugins/FlowHelpers/1.0.0/cliUtils.js b/FlowPlugins/FlowHelpers/1.0.0/cliUtils.js index 32028e83b..210bb5fb4 100644 --- a/FlowPlugins/FlowHelpers/1.0.0/cliUtils.js +++ b/FlowPlugins/FlowHelpers/1.0.0/cliUtils.js @@ -171,6 +171,14 @@ var CLI = /** @class */ (function () { percentage: percentage, }); } + var fps = (0, cliParsers_1.getHandBrakeFps)({ + str: str, + }); + if (fps > 0) { + _this.config.updateWorker({ + fps: fps, + }); + } } else if (_this.config.cli.toLowerCase().includes('ffmpeg')) { var n = str.indexOf('fps');