From ce599ee84abca51565f23ed89f0796c4665a0fcd Mon Sep 17 00:00:00 2001 From: jlw4049 Date: Wed, 24 Jan 2024 15:52:04 -0500 Subject: [PATCH] feat: add a check/prompt box when invalid metadata is extracted (resolves #12) feat: update program to support latest versions of FFMPEG (fixes #13) --- electron/app/main/ipc_handlers/ipcJobHandler.js | 10 ++++++++++ electron/app/renderer/js/renderer.js | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/electron/app/main/ipc_handlers/ipcJobHandler.js b/electron/app/main/ipc_handlers/ipcJobHandler.js index 82e2407..4705a6d 100644 --- a/electron/app/main/ipc_handlers/ipcJobHandler.js +++ b/electron/app/main/ipc_handlers/ipcJobHandler.js @@ -6,6 +6,7 @@ const { } = require("../../../app/main/logToFile"); const path = require("path"); const createConfigStore = require("../../../app/main/configUtils.js"); +const fs = require("fs"); // const getFileObject = require("../../../app/main/fileUtils").changeFileExtension; // function convertFFmpegToPercent(line, durationInSeconds) { @@ -39,6 +40,13 @@ function convertFFmpegFrameCountToPercent(line, totalFrames) { return 0; } +function checkValidOutput(filePath, root) { + const getSize = fs.statSync(filePath).size; + if (getSize == 0) { + root.webContents.send("invalid-output", filePath); + } +} + module.exports = (root) => { let currentJob = 0; const jobQueue = { uncompleted: [], failed: [], inProgress: [] }; @@ -51,6 +59,7 @@ module.exports = (root) => { const modifiedJobCommand = { currentJob: currentJob, fileName: args.fileName, + outputPath: args.outputPath, pipe1: args.pipe1, pipe2: args.pipe2, // duration: args.duration, @@ -181,6 +190,7 @@ module.exports = (root) => { await new Promise((resolve) => { hdrProcess.on("close", (exitCode) => { if (complete) { + checkValidOutput(job.outputPath, root); root.webContents.send("reset-job-progress"); } resolve(); diff --git a/electron/app/renderer/js/renderer.js b/electron/app/renderer/js/renderer.js index 171ec91..9e365fc 100644 --- a/electron/app/renderer/js/renderer.js +++ b/electron/app/renderer/js/renderer.js @@ -355,7 +355,7 @@ addJobButton.addEventListener("click", async function () { "0:v:0", "-c:v:0", "copy", - "-vbsf", + "-bsf:v", "hevc_mp4toannexb", "-f", "hevc", @@ -408,6 +408,7 @@ addJobButton.addEventListener("click", async function () { if (hdr10PlusCheckBox.checked || dVCheckBox.checked) { const addJob = await ipcRenderer.invoke("add-job", { fileName: inputFileName, + outputPath: outputPath, pipe1: pipe1, pipe2: pipe2, frameCount: videoTrackFrameCount, @@ -525,6 +526,13 @@ ipcRenderer.on("job-complete", () => { startJobButton.style.display = "flex"; }); +ipcRenderer.on("invalid-output", (filePath) => { + ipcRenderer.send("show-message-prompt", [ + "Error", + `There was an error parsing metadata, input likely has invalid HDR metadata.\n\nInvalid output:\n${filePath}`, + ]); +}); + ipcRenderer.on("update-job-progress", (progress) => { const computedStyle = window.getComputedStyle(queuePanelProgressBox); if (computedStyle.getPropertyValue("display") !== "flex") {