mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 01:36:08 -07:00
Merge pull request #780 from HaveAGitGat/encoders
chore: export checkHardware()
This commit is contained in:
commit
d1462aae85
2 changed files with 83 additions and 43 deletions
|
|
@ -37,32 +37,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var hardwareUtils_1 = require("./hardwareUtils");
|
var hardwareUtils_1 = require("./hardwareUtils");
|
||||||
var run = function () { return __awaiter(void 0, void 0, void 0, function () {
|
var baseInput = {
|
||||||
var encoderProperties;
|
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) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0: return [4 /*yield*/, (0, hardwareUtils_1.getEncoder)({
|
case 0:
|
||||||
targetCodec: 'h264',
|
input = JSON.parse(JSON.stringify(baseInput));
|
||||||
hardwareEncoding: true,
|
input.args.jobLog = function () {
|
||||||
hardwareType: 'auto',
|
// eslint-disable-next-line no-console
|
||||||
// @ts-expect-error type
|
// console.log(t);
|
||||||
args: {
|
};
|
||||||
workerType: 'transcodegpu',
|
if (settings.targetCodec) {
|
||||||
ffmpegPath: 'ffmpeg',
|
input.targetCodec = settings.targetCodec;
|
||||||
jobLog: function (t) {
|
}
|
||||||
// eslint-disable-next-line no-console
|
if (settings.hardwareEncoding) {
|
||||||
console.log(t);
|
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:
|
case 1:
|
||||||
encoderProperties = _a.sent();
|
encoderProperties = _a.sent();
|
||||||
// eslint-disable-next-line no-console
|
return [2 /*return*/, encoderProperties];
|
||||||
console.log({
|
|
||||||
encoderProperties: encoderProperties,
|
|
||||||
});
|
|
||||||
return [2 /*return*/];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}); };
|
}); };
|
||||||
void run();
|
exports.default = checkHardware;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,52 @@
|
||||||
import { getEncoder } from './hardwareUtils';
|
import { getEncoder, IgetEncoder } from './hardwareUtils';
|
||||||
|
|
||||||
const run = async () => {
|
const baseInput = {
|
||||||
const encoderProperties = await getEncoder({
|
targetCodec: 'h264',
|
||||||
targetCodec: 'h264',
|
hardwareEncoding: true,
|
||||||
hardwareEncoding: true,
|
hardwareType: 'auto',
|
||||||
hardwareType: 'auto',
|
args: {
|
||||||
// @ts-expect-error type
|
workerType: 'transcodegpu',
|
||||||
args: {
|
ffmpegPath: 'ffmpeg',
|
||||||
workerType: 'transcodegpu',
|
jobLog: () => {
|
||||||
ffmpegPath: 'ffmpeg',
|
//
|
||||||
jobLog: (t:string) => {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(t);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log({
|
|
||||||
encoderProperties,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void run();
|
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);
|
||||||
|
|
||||||
|
return encoderProperties;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default checkHardware;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue