From 16be27e8fe514389257d5cdf715ff1805697c3d6 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:33:26 +0100 Subject: [PATCH] Fix 10th gen + qsv --- .../FlowHelpers/1.0.0/hardwareUtils.js | 20 ++++++++++++++++--- .../FlowHelpers/1.0.0/hardwareUtils.ts | 10 ++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.js b/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.js index fe39337c8..9ef83ac86 100644 --- a/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.js +++ b/FlowPlugins/FlowHelpers/1.0.0/hardwareUtils.js @@ -46,10 +46,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEncoder = exports.getBestNvencDevice = exports.hasEncoder = void 0; +var os_1 = __importDefault(require("os")); var hasEncoder = function (_a) { - var ffmpegPath = _a.ffmpegPath, encoder = _a.encoder, inputArgs = _a.inputArgs, filter = _a.filter, args = _a.args; + var ffmpegPath = _a.ffmpegPath, encoder = _a.encoder, inputArgs = _a.inputArgs, outputArgs = _a.outputArgs, 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) { @@ -63,7 +76,7 @@ var hasEncoder = function (_a) { return [4 /*yield*/, new Promise(function (resolve) { 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"); + + " -c:v ".concat(encoder, " ").concat(outputArgs.join(' ') || '', " -f null /dev/null"); args.jobLog("Checking for encoder ".concat(encoder, " with command:")); args.jobLog(command); exec(command, function ( @@ -197,7 +210,7 @@ var getEncoder = function (_a) { '-hwaccel', 'qsv', ], - outputArgs: [], + outputArgs: __spreadArray([], (os_1.default.platform() === 'win32' ? ['-load_plugin', 'hevc_hw'] : []), true), filter: '', }, { @@ -312,6 +325,7 @@ var getEncoder = function (_a) { ffmpegPath: args.ffmpegPath, encoder: gpuEncoder.encoder, inputArgs: gpuEncoder.inputArgs, + outputArgs: gpuEncoder.outputArgs, filter: gpuEncoder.filter, args: args, })]; diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.ts b/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.ts index fe00c97bb..af970f9bd 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/hardwareUtils.ts @@ -1,15 +1,18 @@ +import os from 'os'; import { IpluginInputArgs } from './interfaces/interfaces'; export const hasEncoder = async ({ ffmpegPath, encoder, inputArgs, + outputArgs, filter, args, }: { ffmpegPath: string, encoder: string, inputArgs: string[], + outputArgs: string[], filter: string, args: IpluginInputArgs, }): Promise => { @@ -19,7 +22,7 @@ export const hasEncoder = async ({ isEnabled = await new Promise((resolve) => { 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`; + + ` -c:v ${encoder} ${outputArgs.join(' ') || ''} -f null /dev/null`; args.jobLog(`Checking for encoder ${encoder} with command:`); args.jobLog(command); @@ -180,7 +183,9 @@ export const getEncoder = async ({ '-hwaccel', 'qsv', ], - outputArgs: [], + outputArgs: [ + ...(os.platform() === 'win32' ? ['-load_plugin', 'hevc_hw'] : []), + ], filter: '', }, { @@ -303,6 +308,7 @@ export const getEncoder = async ({ ffmpegPath: args.ffmpegPath, encoder: gpuEncoder.encoder, inputArgs: gpuEncoder.inputArgs, + outputArgs: gpuEncoder.outputArgs, filter: gpuEncoder.filter, args, });