1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-28 01:10:52 +01:00

Updated video code

This commit is contained in:
Feenix 2022-11-26 15:50:44 +05:30
parent 0ce6046350
commit d2e309303f
2 changed files with 78 additions and 2 deletions

View File

@ -16,7 +16,6 @@ import {
app, app,
ipcMain, ipcMain,
dialog, dialog,
ipcRenderer,
shell, shell,
MessageBoxOptions, MessageBoxOptions,
} from "electron"; } from "electron";
@ -349,6 +348,75 @@ ipcMain.on(commands.UPSCAYL_VIDEO, async (event, payload) => {
if (!fs.existsSync(frameExtractionPath)) { if (!fs.existsSync(frameExtractionPath)) {
fs.mkdirSync(frameExtractionPath, { recursive: true }); fs.mkdirSync(frameExtractionPath, { recursive: true });
} }
let ffmpegProcess: ChildProcessWithoutNullStreams | null = null;
ffmpegProcess = spawn(
ffmpeg.path,
[
"-i",
inputDir + "/" + videoFileName,
frameExtractionPath + "/" + "out%d.png",
],
{
cwd: undefined,
detached: false,
}
);
// UPSCALE
let upscayl: ChildProcessWithoutNullStreams | null = null;
upscayl = spawn(
execPath("realesrgan"),
[
"-i",
frameExtractionPath,
"-o",
frameExtractionPath + "_upscaled",
"-s",
4,
"-m",
modelsPath,
"-n",
model,
],
{
cwd: undefined,
detached: false,
}
);
let failed = false;
upscayl?.stderr.on("data", (data) => {
console.log(
"🚀 => upscayl.stderr.on => stderr.toString()",
data.toString()
);
data = data.toString();
mainWindow.webContents.send(
commands.UPSCAYL_VIDEO_PROGRESS,
data.toString()
);
if (data.includes("invalid gpu") || data.includes("failed")) {
failed = true;
}
});
upscayl?.on("error", (data) => {
mainWindow.webContents.send(
commands.UPSCAYL_VIDEO_PROGRESS,
data.toString()
);
failed = true;
return;
});
// Send done comamnd when
upscayl?.on("close", (code) => {
if (failed !== true) {
console.log("Done upscaling");
mainWindow.webContents.send(commands.UPSCAYL_VIDEO_DONE, outputDir);
}
});
}); });
//------------------------Upscayl Folder-----------------------------// //------------------------Upscayl Folder-----------------------------//

View File

@ -299,7 +299,15 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL_VIDEO, (event, payload) => __aw
if (!fs_1.default.existsSync(frameExtractionPath)) { if (!fs_1.default.existsSync(frameExtractionPath)) {
fs_1.default.mkdirSync(frameExtractionPath, { recursive: true }); fs_1.default.mkdirSync(frameExtractionPath, { recursive: true });
} }
console.log(upscayl_ffmpeg_1.default.path()); let ffmpegProcess = null;
ffmpegProcess = (0, child_process_1.spawn)(upscayl_ffmpeg_1.default.path, [
"-i",
inputDir + "/" + videoFileName,
frameExtractionPath + "/" + "out%d.png",
], {
cwd: undefined,
detached: false,
});
})); }));
//------------------------Upscayl Folder-----------------------------// //------------------------Upscayl Folder-----------------------------//
electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () { electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {