1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-24 07:30:19 +01:00
upscayl/main/index.js

498 lines
20 KiB
JavaScript
Raw Normal View History

2022-11-11 21:41:28 +01:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
2023-03-18 13:33:17 +01:00
const getArguments_1 = require("./utils/getArguments");
2022-11-11 21:41:28 +01:00
// Native
const electron_updater_1 = require("electron-updater");
2022-11-11 21:50:20 +01:00
const getPlatform_1 = __importDefault(require("./getPlatform"));
2022-11-23 19:24:30 +01:00
const upscayl_ffmpeg_1 = __importDefault(require("upscayl-ffmpeg"));
2023-03-18 13:33:17 +01:00
const path_1 = require("path");
2023-03-31 12:33:48 +02:00
const electron_log_1 = __importDefault(require("electron-log"));
2023-03-18 13:33:17 +01:00
const url_1 = require("url");
const fs_1 = __importDefault(require("fs"));
2022-11-11 21:41:28 +01:00
const binaries_1 = require("./binaries");
// Packages
const electron_1 = require("electron");
2023-03-18 13:33:17 +01:00
const upscayl_1 = require("./upscayl");
2022-11-11 21:41:28 +01:00
const electron_next_1 = __importDefault(require("electron-next"));
2023-03-18 13:33:17 +01:00
const electron_is_dev_1 = __importDefault(require("electron-is-dev"));
2022-11-11 21:41:28 +01:00
const commands_1 = __importDefault(require("./commands"));
2023-03-31 12:33:48 +02:00
electron_log_1.default.initialize({ preload: true });
2022-11-11 21:41:28 +01:00
// Prepare the renderer once the app is ready
let mainWindow;
electron_1.app.on("ready", () => __awaiter(void 0, void 0, void 0, function* () {
yield (0, electron_next_1.default)("./renderer");
2023-03-31 12:33:48 +02:00
electron_log_1.default.info("🚀 ICON PATH: ", (0, path_1.join)(__dirname, "build", "icon.png"));
electron_log_1.default.info("🚀 UPSCAYL EXEC PATH: ", (0, binaries_1.execPath)(""));
electron_log_1.default.info("🚀 MODELS PATH: ", binaries_1.modelsPath);
electron_log_1.default.info("🚀 FFMPEG PATH: ", upscayl_ffmpeg_1.default.path);
2022-11-11 21:41:28 +01:00
mainWindow = new electron_1.BrowserWindow({
icon: (0, path_1.join)(__dirname, "build", "icon.png"),
2022-12-22 15:59:11 +01:00
width: 1300,
height: 940,
2022-11-11 21:41:28 +01:00
minHeight: 500,
minWidth: 500,
show: false,
backgroundColor: "#171717",
webPreferences: {
nodeIntegration: true,
webSecurity: false,
preload: (0, path_1.join)(__dirname, "preload.js"),
},
});
const url = electron_is_dev_1.default
? "http://localhost:8000"
: (0, url_1.format)({
pathname: (0, path_1.join)(__dirname, "../renderer/out/index.html"),
protocol: "file:",
slashes: true,
});
mainWindow.setMenuBarVisibility(false);
mainWindow.loadURL(url);
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
electron_1.shell.openExternal(url);
return { action: "deny" };
});
mainWindow.once("ready-to-show", () => {
mainWindow.show();
mainWindow.webContents.setZoomFactor(1);
});
if (!electron_is_dev_1.default) {
electron_updater_1.autoUpdater.checkForUpdates();
}
}));
// Quit the app once all windows are closed
electron_1.app.on("window-all-closed", electron_1.app.quit);
2023-03-31 12:33:48 +02:00
electron_log_1.default.log(electron_1.app.getAppPath());
2023-04-09 07:16:15 +02:00
// Path variables for file and folder selection
let imagePath = undefined;
let folderPath = undefined;
let customModelsFolderPath = undefined;
2022-11-11 21:41:28 +01:00
//------------------------Select File-----------------------------//
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(void 0, void 0, void 0, function* () {
const { canceled, filePaths } = yield electron_1.dialog.showOpenDialog({
properties: ["openFile", "multiSelections"],
2023-04-09 07:16:15 +02:00
title: "Select Image",
defaultPath: imagePath,
2022-11-11 21:41:28 +01:00
});
if (canceled) {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("File Operation Cancelled");
2023-04-09 07:16:15 +02:00
return null;
2022-11-11 21:41:28 +01:00
}
else {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("Selected File Path: ", filePaths[0]);
2023-04-09 07:16:15 +02:00
let isValid = false;
imagePath = filePaths[0];
// READ SELECTED FILES
filePaths.forEach((file) => {
// log.log("Files in Folder: ", file);
if (file.endsWith(".png") ||
file.endsWith(".jpg") ||
file.endsWith(".jpeg") ||
file.endsWith(".webp") ||
file.endsWith(".JPG") ||
file.endsWith(".PNG") ||
file.endsWith(".JPEG") ||
file.endsWith(".WEBP")) {
isValid = true;
}
});
if (!isValid) {
const options = {
type: "error",
title: "Invalid File",
message: "The selected file is not a valid image. Make sure you select a '.png', '.jpg', or '.webp' file.",
};
electron_1.dialog.showMessageBoxSync(mainWindow, options);
return null;
}
2022-11-11 21:41:28 +01:00
// CREATE input AND upscaled FOLDER
return filePaths[0];
}
}));
//------------------------Select Folder-----------------------------//
electron_1.ipcMain.handle(commands_1.default.SELECT_FOLDER, (event, message) => __awaiter(void 0, void 0, void 0, function* () {
2023-04-09 07:16:15 +02:00
const { canceled, filePaths: folderPaths } = yield electron_1.dialog.showOpenDialog({
2022-11-11 21:41:28 +01:00
properties: ["openDirectory"],
2023-04-09 07:16:15 +02:00
defaultPath: folderPath,
2022-11-11 21:41:28 +01:00
});
if (canceled) {
2023-04-09 07:16:15 +02:00
return null;
2022-11-11 21:41:28 +01:00
}
else {
2023-04-09 07:16:15 +02:00
electron_log_1.default.log("Selected Folder Path: ", folderPaths[0]);
folderPath = folderPaths[0];
return folderPaths[0];
2023-04-09 05:53:01 +02:00
}
}));
2023-04-09 07:16:15 +02:00
//------------------------Get Model Names-----------------------------//
const getModels = (folderPath) => {
let models = [];
let isValid = false;
// READ CUSTOM MODELS FOLDER
fs_1.default.readdirSync(folderPath).forEach((file) => {
// log.log("Files in Folder: ", file);
if (file.endsWith(".param") ||
file.endsWith(".PARAM") ||
file.endsWith(".bin") ||
file.endsWith(".BIN")) {
isValid = true;
const modelName = file.substring(0, file.lastIndexOf(".")) || file;
if (!models.includes(modelName)) {
models.push(modelName);
}
}
});
if (!isValid) {
const options = {
type: "error",
title: "Invalid Folder",
message: "The selected folder does not contain valid model files. Make sure you select the folder that ONLY contains '.param' and '.bin' files.",
buttons: ["OK"],
};
electron_1.dialog.showMessageBoxSync(options);
return null;
}
return models;
};
2023-04-09 07:48:53 +02:00
electron_1.ipcMain.on(commands_1.default.GET_MODELS_LIST, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
if (payload) {
mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(payload));
}
}));
2023-04-09 05:53:01 +02:00
//------------------------Select Custom Models Folder---------------------//
electron_1.ipcMain.handle(commands_1.default.SELECT_CUSTOM_MODEL_FOLDER, (event, message) => __awaiter(void 0, void 0, void 0, function* () {
2023-04-09 07:16:15 +02:00
const { canceled, filePaths: folderPaths } = yield electron_1.dialog.showOpenDialog({
2023-04-09 05:53:01 +02:00
properties: ["openDirectory"],
2023-04-09 07:16:15 +02:00
title: "Select Custom Models Folder",
defaultPath: customModelsFolderPath,
2023-04-09 05:53:01 +02:00
});
if (canceled) {
2023-04-09 07:16:15 +02:00
return null;
2023-04-09 05:53:01 +02:00
}
else {
2023-04-09 07:16:15 +02:00
electron_log_1.default.log("Custom Folder Path: ", folderPaths[0]);
customModelsFolderPath = folderPaths[0];
mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(customModelsFolderPath));
return customModelsFolderPath;
2022-11-11 21:41:28 +01:00
}
}));
2022-12-02 15:21:42 +01:00
//------------------------Open Folder-----------------------------//
electron_1.ipcMain.on(commands_1.default.OPEN_FOLDER, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log(payload);
2022-12-02 15:21:42 +01:00
electron_1.shell.openPath(payload);
}));
2022-11-11 21:41:28 +01:00
//------------------------Double Upscayl-----------------------------//
electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
const model = payload.model;
2023-03-18 13:33:17 +01:00
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "");
2022-11-11 21:41:28 +01:00
let outputDir = payload.outputPath;
2022-12-16 17:20:46 +01:00
const gpuId = payload.gpuId;
const saveImageAs = payload.saveImageAs;
2022-11-11 21:41:28 +01:00
// COPY IMAGE TO TMP FOLDER
2022-11-11 21:50:20 +01:00
const platform = (0, getPlatform_1.default)();
2022-11-11 21:41:28 +01:00
const fullfileName = platform === "win"
? payload.imagePath.split("\\").slice(-1)[0]
: payload.imagePath.split("/").slice(-1)[0];
const fileName = (0, path_1.parse)(fullfileName).name;
const fileExt = (0, path_1.parse)(fullfileName).ext;
2023-03-18 13:33:17 +01:00
const outFile = outputDir + "/" + fileName + "_upscayl_16x_" + model + "." + saveImageAs;
2023-03-18 12:58:38 +01:00
// UPSCALE
2023-03-18 13:33:17 +01:00
let upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleArguments)(inputDir, fullfileName, outFile, binaries_1.modelsPath, model, gpuId, saveImageAs));
2022-11-11 21:41:28 +01:00
let failed = false;
2022-12-27 07:45:16 +01:00
let isAlpha = false;
2023-03-18 13:33:17 +01:00
let failed2 = false;
const onData = (data) => {
2022-11-11 21:41:28 +01:00
// CONVERT DATA TO STRING
data = data.toString();
// PRINT TO CONSOLE
2023-04-08 08:53:32 +02:00
electron_log_1.default.log(data);
2022-11-11 21:41:28 +01:00
// SEND UPSCAYL PROGRESS TO RENDERER
mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data);
// IF PROGRESS HAS ERROR, UPSCAYL FAILED
if (data.includes("invalid gpu") || data.includes("failed")) {
failed = true;
}
2022-12-27 07:45:16 +01:00
if (data.includes("has alpha channel")) {
isAlpha = true;
}
2023-03-18 13:33:17 +01:00
};
const onError = (data) => {
2022-11-11 21:41:28 +01:00
data.toString();
// SEND UPSCAYL PROGRESS TO RENDERER
mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data);
// SET FAILED TO TRUE
failed = true;
return;
2023-03-18 13:33:17 +01:00
};
const onData2 = (data) => {
// CONVERT DATA TO STRING
data = data.toString();
// PRINT TO CONSOLE
2023-04-08 08:53:32 +02:00
electron_log_1.default.log(data);
2023-03-18 13:33:17 +01:00
// SEND UPSCAYL PROGRESS TO RENDERER
mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data);
// IF PROGRESS HAS ERROR, UPSCAYL FAILED
if (data.includes("invalid gpu") || data.includes("failed")) {
failed2 = true;
}
};
const onError2 = (data) => {
data.toString();
// SEND UPSCAYL PROGRESS TO RENDERER
mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data);
// SET FAILED TO TRUE
failed2 = true;
return;
};
const onClose2 = (code) => {
if (!failed2) {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("Done upscaling");
2023-03-18 13:33:17 +01:00
mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_DONE, isAlpha ? outFile + ".png" : outFile);
}
};
upscayl.process.stderr.on("data", onData);
upscayl.process.on("error", onError);
upscayl.process.on("close", (code) => {
2022-11-11 21:41:28 +01:00
// IF NOT FAILED
if (!failed) {
2023-03-18 12:58:38 +01:00
// UPSCALE
2023-03-18 13:33:17 +01:00
let upscayl2 = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleSecondPassArguments)(isAlpha, outFile, binaries_1.modelsPath, model, gpuId, saveImageAs));
upscayl2.process.stderr.on("data", onData2);
upscayl2.process.on("error", onError2);
upscayl2.process.on("close", onClose2);
2022-11-11 21:41:28 +01:00
}
});
}));
//------------------------Image Upscayl-----------------------------//
electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
const model = payload.model;
const scale = payload.scaleFactor;
2022-12-16 17:20:46 +01:00
const gpuId = payload.gpuId;
const saveImageAs = payload.saveImageAs;
2023-03-18 13:33:17 +01:00
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "");
2022-11-11 21:41:28 +01:00
let outputDir = payload.outputPath;
// COPY IMAGE TO TMP FOLDER
2022-11-26 10:42:16 +01:00
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "");
2022-11-11 21:41:28 +01:00
const fileName = (0, path_1.parse)(fullfileName).name;
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("🚀 => fileName", fileName);
2022-11-11 21:41:28 +01:00
const fileExt = (0, path_1.parse)(fullfileName).ext;
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("🚀 => fileExt", fileExt);
2023-03-18 13:33:17 +01:00
const outFile = outputDir +
"/" +
fileName +
"_upscayl_" +
scale +
"x_" +
model +
"." +
saveImageAs;
2022-11-11 21:41:28 +01:00
// UPSCALE
if (fs_1.default.existsSync(outFile)) {
// If already upscayled, just output that file
mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, outFile);
}
2022-11-25 08:30:03 +01:00
else {
2023-03-18 13:33:17 +01:00
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getSingleImageArguments)(inputDir, fullfileName, outFile, binaries_1.modelsPath, model, scale, gpuId, saveImageAs));
2022-12-27 07:45:16 +01:00
let isAlpha = false;
2022-11-25 08:30:03 +01:00
let failed = false;
2023-03-12 10:49:02 +01:00
const onData = (data) => {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("image upscayl: ", data.toString());
2022-11-25 08:30:03 +01:00
data = data.toString();
mainWindow.webContents.send(commands_1.default.UPSCAYL_PROGRESS, data.toString());
if (data.includes("invalid gpu") || data.includes("failed")) {
failed = true;
}
2022-12-27 07:45:16 +01:00
if (data.includes("has alpha channel")) {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!");
2022-12-27 07:45:16 +01:00
isAlpha = true;
}
2023-03-12 10:49:02 +01:00
};
const onError = (data) => {
2022-11-25 08:30:03 +01:00
mainWindow.webContents.send(commands_1.default.UPSCAYL_PROGRESS, data.toString());
failed = true;
return;
2023-03-12 10:49:02 +01:00
};
const onClose = () => {
2022-11-25 08:30:03 +01:00
if (failed !== true) {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("Done upscaling");
2022-12-27 07:45:16 +01:00
mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, isAlpha ? outFile + ".png" : outFile);
2022-11-25 08:30:03 +01:00
}
2023-03-12 10:49:02 +01:00
};
upscayl.process.stderr.on("data", onData);
upscayl.process.on("error", onError);
upscayl.process.on("close", onClose);
2022-11-25 08:30:03 +01:00
}
}));
2022-11-11 21:41:28 +01:00
//------------------------Upscayl Folder-----------------------------//
electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
2022-12-02 15:21:42 +01:00
// GET THE MODEL
2022-11-11 21:41:28 +01:00
const model = payload.model;
2022-12-16 17:20:46 +01:00
const gpuId = payload.gpuId;
const saveImageAs = payload.saveImageAs;
2022-12-02 15:21:42 +01:00
// GET THE IMAGE DIRECTORY
2022-11-11 21:41:28 +01:00
let inputDir = payload.batchFolderPath;
2022-12-02 15:21:42 +01:00
// GET THE OUTPUT DIRECTORY
2023-03-18 13:33:17 +01:00
let outputDir = payload.outputPath;
2022-11-11 21:41:28 +01:00
if (!fs_1.default.existsSync(outputDir)) {
fs_1.default.mkdirSync(outputDir, { recursive: true });
}
// UPSCALE
2023-03-18 13:33:17 +01:00
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getBatchArguments)(inputDir, outputDir, binaries_1.modelsPath, model, gpuId, saveImageAs));
2022-11-11 21:41:28 +01:00
let failed = false;
2023-03-18 13:33:17 +01:00
const onData = (data) => {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
2022-11-11 21:41:28 +01:00
data = data.toString();
mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_PROGRESS, data.toString());
if (data.includes("invalid gpu") || data.includes("failed")) {
failed = true;
}
2023-03-18 13:33:17 +01:00
};
const onError = (data) => {
2022-11-11 21:41:28 +01:00
mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_PROGRESS, data.toString());
failed = true;
return;
2023-03-18 13:33:17 +01:00
};
const onClose = () => {
2022-11-11 21:41:28 +01:00
if (failed !== true) {
2023-04-08 08:53:32 +02:00
electron_log_1.default.log("Done upscaling");
2022-11-11 21:41:28 +01:00
mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_DONE, outputDir);
}
2023-03-18 13:33:17 +01:00
};
upscayl.process.stderr.on("data", onData);
upscayl.process.on("error", onError);
upscayl.process.on("close", onClose);
2022-12-16 17:20:46 +01:00
}));
2022-11-11 21:41:28 +01:00
//------------------------Auto-Update Code-----------------------------//
// ! AUTO UPDATE STUFF
electron_updater_1.autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {
const dialogOpts = {
type: "info",
2023-03-18 13:33:17 +01:00
buttons: ["Ok cool"],
title: "New Upscayl Update",
message: releaseName,
detail: "A new version is being downloaded. Please check GitHub for more details.",
2022-11-11 21:41:28 +01:00
};
electron_1.dialog.showMessageBox(dialogOpts).then((returnValue) => { });
});
electron_updater_1.autoUpdater.on("update-downloaded", (event) => {
const dialogOpts = {
type: "info",
buttons: ["Restart", "Later"],
2023-03-18 13:33:17 +01:00
title: "New Upscayl Update",
message: event.releaseName,
2022-11-11 21:41:28 +01:00
detail: "A new version has been downloaded. Restart the application to apply the updates.",
};
electron_1.dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0)
electron_updater_1.autoUpdater.quitAndInstall();
});
});
2023-03-18 13:33:17 +01:00
//------------------------Video Upscayl-----------------------------//
// ipcMain.on(commands.UPSCAYL_VIDEO, async (event, payload) => {
// // Extract the model
// const model = payload.model;
// // Extract the Video Directory
// let videoFileName = payload.videoPath.replace(/^.*[\\\/]/, "");
// const justFileName = parse(videoFileName).name;
// let inputDir = payload.videoPath.match(/(.*)[\/\\]/)[1] || "";
2023-04-08 08:53:32 +02:00
// log.log("🚀 => file: index.ts => line 337 => inputDir", inputDir);
2023-03-18 13:33:17 +01:00
// // Set the output directory
// let outputDir = payload.outputPath + "_frames";
2023-04-08 08:53:32 +02:00
// log.log("🚀 => file: index.ts => line 340 => outputDir", outputDir);
2023-03-18 13:33:17 +01:00
// let frameExtractionPath = join(inputDir, justFileName + "_f");
// let frameUpscalePath = join(inputDir, justFileName + "_u");
2023-04-08 08:53:32 +02:00
// log.log(
2023-03-18 13:33:17 +01:00
// "🚀 => file: index.ts => line 342 => frameExtractionPath",
// frameExtractionPath,
// frameUpscalePath
// );
// if (!fs.existsSync(frameExtractionPath)) {
// fs.mkdirSync(frameExtractionPath, { recursive: true });
// }
// if (!fs.existsSync(frameUpscalePath)) {
// fs.mkdirSync(frameUpscalePath, { recursive: true });
// }
// let ffmpegProcess: ChildProcessWithoutNullStreams | null = null;
// ffmpegProcess = spawn(
// ffmpeg.path,
// [
// "-i",
// inputDir + "/" + videoFileName,
// frameExtractionPath + "/" + "out%d.png",
// ],
// {
// cwd: undefined,
// detached: false,
// }
// );
// let failed = false;
// ffmpegProcess?.stderr.on("data", (data: string) => {
2023-04-08 08:53:32 +02:00
// log.log("🚀 => file: index.ts:420 => data", data.toString());
2023-03-18 13:33:17 +01:00
// data = data.toString();
// mainWindow.webContents.send(
// commands.FFMPEG_VIDEO_PROGRESS,
// data.toString()
// );
// });
// ffmpegProcess?.on("error", (data: string) => {
// mainWindow.webContents.send(
// commands.FFMPEG_VIDEO_PROGRESS,
// data.toString()
// );
// failed = true;
// return;
// });
// // Send done comamnd when
// ffmpegProcess?.on("close", (code: number) => {
// if (failed !== true) {
2023-04-08 08:53:32 +02:00
// log.log("Frame extraction successful!");
2023-03-18 13:33:17 +01:00
// mainWindow.webContents.send(commands.FFMPEG_VIDEO_DONE, outputDir);
// // UPSCALE
// let upscayl: ChildProcessWithoutNullStreams | null = null;
// upscayl = spawn(
// execPath("realesrgan"),
// [
// "-i",
// frameExtractionPath,
// "-o",
// frameUpscalePath,
// "-s",
// 4,
// "-m",
// modelsPath,
// "-n",
// model,
// ],
// {
// cwd: undefined,
// detached: false,
// }
// );
// upscayl?.stderr.on("data", (data) => {
2023-04-08 08:53:32 +02:00
// log.log(
2023-03-18 13:33:17 +01:00
// "🚀 => upscayl.stderr.on => stderr.toString()",
// data.toString()
// );
// data = data.toString();
// mainWindow.webContents.send(
// commands.FFMPEG_VIDEO_PROGRESS,
// data.toString()
// );
// });
// }
// });
// });