Skip to content

Commit

Permalink
Add encoder detection logging
Browse files Browse the repository at this point in the history
  • Loading branch information
HaveAGitGat committed Oct 4, 2023
1 parent e782244 commit bd74a0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEncoder = exports.getBestNvencDevice = exports.hasEncoder = void 0;
var hasEncoder = function (_a) {
var ffmpegPath = _a.ffmpegPath, encoder = _a.encoder, inputArgs = _a.inputArgs, filter = _a.filter;
var ffmpegPath = _a.ffmpegPath, encoder = _a.encoder, inputArgs = _a.inputArgs, filter = _a.filter, args = _a.args;
return __awaiter(void 0, void 0, void 0, function () {
var exec, isEnabled, err_1;
return __generator(this, function (_b) {
Expand All @@ -64,6 +64,8 @@ var hasEncoder = function (_a) {
var command = "".concat(ffmpegPath, " ").concat(inputArgs.join(' ') || '', " -f lavfi -i color=c=black:s=256x256:d=1:r=30")
+ " ".concat(filter || '')
+ " -c:v ".concat(encoder, " -f null /dev/null");
args.jobLog("Checking for encoder ".concat(encoder, " with command:"));
args.jobLog(command);
exec(command, function (
// eslint-disable-next-line
error) {
Expand All @@ -76,6 +78,7 @@ var hasEncoder = function (_a) {
})];
case 2:
isEnabled = _b.sent();
args.jobLog("Encoder ".concat(encoder, " is ").concat(isEnabled ? 'enabled' : 'disabled'));
return [3 /*break*/, 4];
case 3:
err_1 = _b.sent();
Expand Down Expand Up @@ -310,6 +313,7 @@ var getEncoder = function (_a) {
encoder: gpuEncoder.encoder,
inputArgs: gpuEncoder.inputArgs,
filter: gpuEncoder.filter,
args: args,
})];
case 2:
// eslint-disable-next-line no-await-in-loop
Expand Down
9 changes: 9 additions & 0 deletions FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export const hasEncoder = async ({
encoder,
inputArgs,
filter,
args,
}: {
ffmpegPath: string,
encoder: string,
inputArgs: string[],
filter: string,
args: IpluginInputArgs,
}): Promise<boolean> => {
const { exec } = require('child_process');
let isEnabled = false;
Expand All @@ -18,6 +20,10 @@ export const hasEncoder = async ({
const command = `${ffmpegPath} ${inputArgs.join(' ') || ''} -f lavfi -i color=c=black:s=256x256:d=1:r=30`
+ ` ${filter || ''}`
+ ` -c:v ${encoder} -f null /dev/null`;

args.jobLog(`Checking for encoder ${encoder} with command:`);
args.jobLog(command);

exec(command, (
// eslint-disable-next-line
error: any,
Expand All @@ -31,6 +37,8 @@ export const hasEncoder = async ({
resolve(true);
});
});

args.jobLog(`Encoder ${encoder} is ${isEnabled ? 'enabled' : 'disabled'}`);
} catch (err) {
// eslint-disable-next-line no-console
console.log(err);
Expand Down Expand Up @@ -296,6 +304,7 @@ export const getEncoder = async ({
encoder: gpuEncoder.encoder,
inputArgs: gpuEncoder.inputArgs,
filter: gpuEncoder.filter,
args,
});
}

Expand Down

0 comments on commit bd74a0e

Please sign in to comment.