Merge pull request #504 from HaveAGitGat/add_notify

Update hw check
make-only-subtitle-default
HaveAGitGat 2 years ago committed by GitHub
commit 0a2053c0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,30 +64,62 @@ var os_1 = __importDefault(require("os"));
var hasEncoder = function (_a) { var hasEncoder = function (_a) {
var ffmpegPath = _a.ffmpegPath, encoder = _a.encoder, inputArgs = _a.inputArgs, outputArgs = _a.outputArgs, 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 () { return __awaiter(void 0, void 0, void 0, function () {
var exec, isEnabled, err_1; var spawn, isEnabled, commandArr_1, err_1;
return __generator(this, function (_b) { return __generator(this, function (_b) {
switch (_b.label) { switch (_b.label) {
case 0: case 0:
exec = require('child_process').exec; spawn = require('child_process').spawn;
isEnabled = false; isEnabled = false;
_b.label = 1; _b.label = 1;
case 1: case 1:
_b.trys.push([1, 3, , 4]); _b.trys.push([1, 3, , 4]);
commandArr_1 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], inputArgs, true), [
'-f',
'lavfi',
'-i',
'color=c=black:s=256x256:d=1:r=30'
], false), (filter ? filter.split(' ') : []), true), [
'-c:v',
encoder
], false), outputArgs, true), [
'-f',
'null',
'/dev/null',
], false);
args.jobLog("Checking for encoder ".concat(encoder, " with command:"));
args.jobLog(ffmpegPath + ' ' + commandArr_1.join(' '));
return [4 /*yield*/, new Promise(function (resolve) { 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") var error = function () {
+ " ".concat(filter || '') resolve(false);
+ " -c:v ".concat(encoder, " ").concat(outputArgs.join(' ') || '', " -f null /dev/null"); };
args.jobLog("Checking for encoder ".concat(encoder, " with command:")); var stderr = '';
args.jobLog(command); try {
exec(command, function ( var thread = spawn(ffmpegPath, commandArr_1);
// eslint-disable-next-line thread.on('error', function () {
error) { // catches execution error (bad file)
if (error) { error();
resolve(false); });
return; thread.stdout.on('data', function (data) {
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve(true); stderr += data;
}); });
thread.stderr.on('data', function (data) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
stderr += data;
});
thread.on('close', function (code) {
if (code !== 0) {
error();
}
else {
resolve(true);
}
});
}
catch (err) {
// catches execution error (no file)
error();
}
})]; })];
case 2: case 2:
isEnabled = _b.sent(); isEnabled = _b.sent();

@ -16,29 +16,61 @@ export const hasEncoder = async ({
filter: string, filter: string,
args: IpluginInputArgs, args: IpluginInputArgs,
}): Promise<boolean> => { }): Promise<boolean> => {
const { exec } = require('child_process'); const { spawn } = require('child_process');
let isEnabled = false; let isEnabled = false;
try { try {
const commandArr = [
...inputArgs,
'-f',
'lavfi',
'-i',
'color=c=black:s=256x256:d=1:r=30',
...(filter ? filter.split(' ') : []),
'-c:v',
encoder,
...outputArgs,
'-f',
'null',
'/dev/null',
];
args.jobLog(`Checking for encoder ${encoder} with command:`);
args.jobLog(`${ffmpegPath} ${commandArr.join(' ')}`);
isEnabled = await new Promise((resolve) => { isEnabled = await new Promise((resolve) => {
const command = `${ffmpegPath} ${inputArgs.join(' ') || ''} -f lavfi -i color=c=black:s=256x256:d=1:r=30` const error = () => {
+ ` ${filter || ''}` resolve(false);
+ ` -c:v ${encoder} ${outputArgs.join(' ') || ''} -f null /dev/null`; };
let stderr = '';
args.jobLog(`Checking for encoder ${encoder} with command:`);
args.jobLog(command); try {
const thread = spawn(ffmpegPath, commandArr);
exec(command, ( thread.on('error', () => {
// eslint-disable-next-line // catches execution error (bad file)
error: any, error();
// stdout, });
// stderr,
) => { thread.stdout.on('data', (data: string) => {
if (error) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve(false); stderr += data;
return; });
}
resolve(true); thread.stderr.on('data', (data: string) => {
}); // eslint-disable-next-line @typescript-eslint/no-unused-vars
stderr += data;
});
thread.on('close', (code: number) => {
if (code !== 0) {
error();
} else {
resolve(true);
}
});
} catch (err) {
// catches execution error (no file)
error();
}
}); });
args.jobLog(`Encoder ${encoder} is ${isEnabled ? 'enabled' : 'disabled'}`); args.jobLog(`Encoder ${encoder} is ${isEnabled ? 'enabled' : 'disabled'}`);

Loading…
Cancel
Save