The swiss army knife of lossless video/audio editing
refactor
Mikael Finstad250622f9553f
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex 71653db1..23d6ad4a 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -1781,15 +1781,13 @@ function App() {lastOpenedPathRef.current = filePaths[0]!;+ let firstFilePath = filePaths[0]!;+// first check if it is a single directory, and if so, read it recursively- if (filePaths.length === 1) {- const firstFilePath = filePaths[0]!;- const firstFileStat = await lstat(firstFilePath);- if (firstFileStat.isDirectory()) {- console.log('Reading directory...');- invariant(firstFilePath != null);- filePaths = await readDirRecursively(firstFilePath);- }+ if (filePaths.length === 1 && (await lstat(firstFilePath)).isDirectory()) {+ console.log('Reading directory...');+ invariant(firstFilePath != null);+ filePaths = await readDirRecursively(firstFilePath);}// Only allow opening regular files@@ -1816,7 +1814,7 @@ function App() {}// filePaths.length is now 1- const [firstFilePath] = filePaths;+ firstFilePath = filePaths[0]!;invariant(firstFilePath != null);// https://en.wikibooks.org/wiki/Inside_DVD-Video/Directory_Structurediff --git a/src/renderer/src/ffmpeg.ts b/src/renderer/src/ffmpeg.tsindex fb17c677..26eb375d 100644--- a/src/renderer/src/ffmpeg.ts+++ b/src/renderer/src/ffmpeg.ts@@ -198,19 +198,19 @@ export function findNearestKeyFrameTime({ frames, time, direction, fps }: { framexport function tryMapChaptersToEdl(chapters: FFprobeChapter[]) {try {- return chapters.map((chapter) => {+ return chapters.flatMap((chapter) => {const start = parseFloat(chapter.start_time);const end = parseFloat(chapter.end_time);- if (Number.isNaN(start) || Number.isNaN(end)) return undefined;+ if (Number.isNaN(start) || Number.isNaN(end)) return [];const name = chapter.tags && typeof chapter.tags.title === 'string' ? chapter.tags.title : undefined;- return {+ return [{start,end,name,- };- }).flatMap((it) => (it ? [it] : []));+ }];+ });} catch (err) {console.error('Failed to read chapters from file', err);return [];