From 24fb022b2cc7d0529f8381e0bfe0faa878aa849f Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:24:33 +0000 Subject: [PATCH 1/2] chore: export checkHardware() --- .../FlowHelpers/1.0.0/hardwareUtils.test.ts | 69 +++++++++++++------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.test.ts b/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.test.ts index 5f5a90bd4..6db06a680 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.test.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.test.ts @@ -1,25 +1,52 @@ -import { getEncoder } from './hardwareUtils'; - -const run = async () => { - const encoderProperties = await getEncoder({ - targetCodec: 'h264', - hardwareEncoding: true, - hardwareType: 'auto', - // @ts-expect-error type - args: { - workerType: 'transcodegpu', - ffmpegPath: 'ffmpeg', - jobLog: (t:string) => { - // eslint-disable-next-line no-console - console.log(t); - }, +import { getEncoder, IgetEncoder } from './hardwareUtils'; + +const baseInput = { + targetCodec: 'h264', + hardwareEncoding: true, + hardwareType: 'auto', + args: { + workerType: 'transcodegpu', + ffmpegPath: 'ffmpeg', + jobLog: () => { + // }, - }); + }, +}; + +interface IcheckHardware { + targetCodec:string | undefined, + hardwareEncoding:boolean | undefined, + hardwareType:string | undefined, + ffmpegPath:string | undefined, +} + +const checkHardware = async (settings:IcheckHardware):Promise => { + const input = JSON.parse(JSON.stringify(baseInput)); + + input.args.jobLog = () => { + // eslint-disable-next-line no-console + // console.log(t); + }; + + if (settings.targetCodec) { + input.targetCodec = settings.targetCodec; + } + + if (settings.hardwareEncoding) { + input.hardwareEncoding = settings.hardwareEncoding; + } + + if (settings.hardwareType) { + input.hardwareType = settings.hardwareType; + } + + if (settings.ffmpegPath) { + input.args.ffmpegPath = settings.ffmpegPath; + } + + const encoderProperties = await getEncoder(input); - // eslint-disable-next-line no-console - console.log({ - encoderProperties, - }); + return encoderProperties; }; -void run(); +export default checkHardware; From 547901c3256dc4174c03840e92964f8b2a2c8315 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:26:24 +0000 Subject: [PATCH 2/2] Apply auto-build changes --- .../FlowHelpers/1.0.0/hardwareUtils.test.js | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.test.js b/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.test.js index 1211dee56..71e35b7c6 100644 --- a/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.test.js +++ b/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.test.js @@ -37,32 +37,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); var hardwareUtils_1 = require("./hardwareUtils"); -var run = function () { return __awaiter(void 0, void 0, void 0, function () { - var encoderProperties; +var baseInput = { + targetCodec: 'h264', + hardwareEncoding: true, + hardwareType: 'auto', + args: { + workerType: 'transcodegpu', + ffmpegPath: 'ffmpeg', + jobLog: function () { + // + }, + }, +}; +var checkHardware = function (settings) { return __awaiter(void 0, void 0, void 0, function () { + var input, encoderProperties; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, (0, hardwareUtils_1.getEncoder)({ - targetCodec: 'h264', - hardwareEncoding: true, - hardwareType: 'auto', - // @ts-expect-error type - args: { - workerType: 'transcodegpu', - ffmpegPath: 'ffmpeg', - jobLog: function (t) { - // eslint-disable-next-line no-console - console.log(t); - }, - }, - })]; + case 0: + input = JSON.parse(JSON.stringify(baseInput)); + input.args.jobLog = function () { + // eslint-disable-next-line no-console + // console.log(t); + }; + if (settings.targetCodec) { + input.targetCodec = settings.targetCodec; + } + if (settings.hardwareEncoding) { + input.hardwareEncoding = settings.hardwareEncoding; + } + if (settings.hardwareType) { + input.hardwareType = settings.hardwareType; + } + if (settings.ffmpegPath) { + input.args.ffmpegPath = settings.ffmpegPath; + } + return [4 /*yield*/, (0, hardwareUtils_1.getEncoder)(input)]; case 1: encoderProperties = _a.sent(); - // eslint-disable-next-line no-console - console.log({ - encoderProperties: encoderProperties, - }); - return [2 /*return*/]; + return [2 /*return*/, encoderProperties]; } }); }); }; -void run(); +exports.default = checkHardware;