Skip to content

Commit

Permalink
Merge pull request #780 from HaveAGitGat/encoders
Browse files Browse the repository at this point in the history
chore: export checkHardware()
  • Loading branch information
HaveAGitGat authored Feb 20, 2025
2 parents 064adb5 + 547901c commit d1462aa
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 43 deletions.
57 changes: 35 additions & 22 deletions FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
69 changes: 48 additions & 21 deletions FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.test.ts
Original file line number Diff line number Diff line change
@@ -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<IgetEncoder> => {
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;

0 comments on commit d1462aa

Please sign in to comment.