Skip to content

The swiss army knife of lossless video/audio editing

Detect missing source file when extracting frames and tracks too

Claude9820b32856f0
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 35cf77de..1cb50d99 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -1706,6 +1706,8 @@ function App() {
if (err instanceof RefuseOverwriteError) {
showRefuseToOverwrite();
+ } else if (err instanceof UserFacingError) {
+ errorToast(err.message);
} else {
errorToast(i18n.t('Failed to extract all streams'));
console.error('Failed to extract all streams', err);
@@ -2248,6 +2250,8 @@ function App() {
if (err instanceof RefuseOverwriteError) {
showRefuseToOverwrite();
+ } else if (err instanceof UserFacingError) {
+ errorToast(err.message);
} else {
errorToast(i18n.t('Failed to extract track'));
console.error('Failed to extract track', err);
diff --git a/src/renderer/src/hooks/useFrameCapture.ts b/src/renderer/src/hooks/useFrameCapture.ts
index 78812f21..5e6add74 100644
--- a/src/renderer/src/hooks/useFrameCapture.ts
+++ b/src/renderer/src/hooks/useFrameCapture.ts
@@ -2,7 +2,7 @@ import { dataUriToBuffer } from 'data-uri-to-buffer';
import pMap from 'p-map';
import { useCallback } from 'react';
-import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp, fsOperationWithRetry } from '../util';
+import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp, fsOperationWithRetry, assertFileExists } from '../util';
import { getNumDigits, isDurationValid } from '../segments';
import * as ffmpeg from '../ffmpeg';
@@ -45,6 +45,9 @@ export default ({ appendFfmpegCommandLog, formatTimecode, treatInputFileModified
onProgress: (a: number) => void,
outputTimestamps: boolean,
}) => {
+ // fail fast with a helpful message if the source file has been moved/deleted since it was opened
+ await assertFileExists(filePath);
+
const getSuffix = (prefix: string) => `${prefix}.${captureFormat}`;
if (!outputTimestamps) {
@@ -98,6 +101,8 @@ export default ({ appendFfmpegCommandLog, formatTimecode, treatInputFileModified
captureFormat: CaptureFormat,
quality: number,
}) => {
+ await assertFileExists(filePath);
+
const timecode = formatTimecode({ seconds: time, fileNameFriendly: true });
const nameSuffix = `${timecode}.${captureFormat}`;
const outPath = getSuffixedOutPath({ customOutDir, filePath, nameSuffix });