Skip to content

Commit

Permalink
Merge pull request #652 from HaveAGitGat/hb_fps
Browse files Browse the repository at this point in the history
Update worker with hb fps if available
  • Loading branch information
HaveAGitGat committed Jun 1, 2024
2 parents 04bc128 + 808e43e commit a5714eb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
20 changes: 19 additions & 1 deletion FlowPlugins/FlowHelpers/1.0.0/cliParsers.js
Original file line number Diff line number Diff line change
@@ -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') {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions FlowPlugins/FlowHelpers/1.0.0/cliUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
23 changes: 23 additions & 0 deletions FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -227,5 +249,6 @@ export {
ffmpegParser,
getFFmpegPercentage,
getFFmpegVar,
getHandBrakeFps,
editreadyParser,
};
14 changes: 13 additions & 1 deletion FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a5714eb

Please sign in to comment.