Skip to content

Commit

Permalink
feat: add a check/prompt box when invalid metadata is extracted (reso…
Browse files Browse the repository at this point in the history
…lves #12)

feat: update program to support latest versions of FFMPEG (fixes #13)
  • Loading branch information
jessielw committed Jan 24, 2024
1 parent 0d4ed7c commit ce599ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions electron/app/main/ipc_handlers/ipcJobHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: [] };
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion electron/app/renderer/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ addJobButton.addEventListener("click", async function () {
"0:v:0",
"-c:v:0",
"copy",
"-vbsf",
"-bsf:v",
"hevc_mp4toannexb",
"-f",
"hevc",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit ce599ee

Please sign in to comment.