Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
closes #2197
mifi committed Oct 22, 2024
1 parent 6ddb397 commit dedf301
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/ffmpeg.ts
Original file line number Diff line number Diff line change
@@ -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[]) {
8 changes: 6 additions & 2 deletions src/renderer/src/hooks/useFfmpegOperations.ts
Original file line number Diff line number Diff line change
@@ -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,
];

0 comments on commit dedf301

Please sign in to comment.