From de983c880201ebe297258d0fcd85b340e1c31d44 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 11 Jul 2024 13:55:29 +0200 Subject: [PATCH] fix crash when no audio stream --- src/main.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index fbf75e3..2bba00d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -102,7 +102,7 @@ app.whenReady().then(() => { ) ) { // Only one audio in the file - outFile = getNewFilename(file, "(processed) "); + outFile = getNewFilename(file, "(nomerge) "); nbTracks += 1; // Do a copy @@ -112,7 +112,20 @@ app.whenReady().then(() => { ${extraArgs} \ "${outFile}"`).catch((e) => registerError(win, e)); - // We throw the error since we do not want to merge any audio + // We throw an error since we do not want to merge any audio + return Promise.resolve("skip"); + } else if (`${e}`.includes("matches no stream")) { + // No audio in the file + outFile = getNewFilename(file, "(noaudio) "); + + // Do a copy + await execute(`"${ffmpegPath}" -y \ + -i "${file}" \ + -codec copy \ + ${extraArgs} \ + "${outFile}"`).catch((e) => registerError(win, e)); + + // We throw an error since we do not want to merge any audio return Promise.resolve("skip"); } else { // Error handling