From dedf301810adcec72f95cadadb3c8c1f44fc7234 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 22 Oct 2024 14:39:46 +0200 Subject: [PATCH] fix crash closes #2197 --- src/main/ffmpeg.ts | 5 +++-- src/renderer/src/hooks/useFfmpegOperations.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/ffmpeg.ts b/src/main/ffmpeg.ts index 1dcc2cc5..8713b9ce 100644 --- a/src/main/ffmpeg.ts +++ b/src/main/ffmpeg.ts @@ -25,11 +25,12 @@ export function setCustomFfPath(path: string | undefined) { } function escapeCliArg(arg: string) { + // todo change String(arg) => arg when ts no-implicit-any is turned on if (isWindows) { // https://github.com/mifi/lossless-cut/issues/2151 - return /[\s"&<>^|]/.test(arg) ? `"${arg.replaceAll('"', '""')}"` : arg; + return /[\s"&<>^|]/.test(arg) ? `"${String(arg).replaceAll('"', '""')}"` : arg; } - return /[^\w-]/.test(arg) ? `'${arg.replaceAll("'", '\'"\'"\'')}'` : arg; + return /[^\w-]/.test(arg) ? `'${String(arg).replaceAll("'", '\'"\'"\'')}'` : arg; } export function getFfCommandLine(cmd: string, args: readonly string[]) { diff --git a/src/renderer/src/hooks/useFfmpegOperations.ts b/src/renderer/src/hooks/useFfmpegOperations.ts index 238669f7..7322cb7f 100644 --- a/src/renderer/src/hooks/useFfmpegOperations.ts +++ b/src/renderer/src/hooks/useFfmpegOperations.ts @@ -615,7 +615,11 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea // This is just used to load something into the player with correct duration, // so that the user can seek and then we render frames using ffmpeg & MediaSource - const html5ifyDummy = useCallback(async ({ filePath: filePathArg, outPath, onProgress }) => { + const html5ifyDummy = useCallback(async ({ filePath: filePathArg, outPath, onProgress }: { + filePath: string, + outPath: string, + onProgress: (p: number) => void, + }) => { console.log('Making ffmpeg-assisted dummy file', { filePathArg, outPath }); const duration = await getDuration(filePathArg); @@ -625,7 +629,7 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea // This is just a fast way of generating an empty dummy file '-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100', - '-t', duration, + '-t', String(duration), '-acodec', 'flac', '-y', outPath, ];