diff --git a/src/App.jsx b/src/App.jsx index ad018c2e..bceadca4 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1677,6 +1677,7 @@ const App = memo(() => { await loadMedia({ filePath: path, customOutDir: newCustomOutDir, projectPath }); }, [ensureAccessibleDirectories, loadMedia, storeProjectInWorkingDir]); + // todo merge with userOpenFiles? const batchOpenSingleFile = useCallback(async (path) => { if (workingRef.current) return; if (filePath === path) return; diff --git a/src/ffmpeg.js b/src/ffmpeg.js index ff45edae..1cc34bf9 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -285,7 +285,15 @@ export async function readFileMeta(filePath) { '-of', 'json', '-show_chapters', '-show_format', '-show_entries', 'stream', '-i', filePath, '-hide_banner', ]); - const { streams = [], format = {}, chapters = [] } = JSON.parse(stdout); + let parsedJson; + try { + // https://github.com/mifi/lossless-cut/issues/1342 + parsedJson = JSON.parse(stdout); + } catch (err) { + console.log('ffprobe stdout', stdout); + throw new Error('ffprobe returned malformed data'); + } + const { streams = [], format = {}, chapters = [] } = parsedJson; return { format, streams, chapters }; } catch (err) { // Windows will throw error with code ENOENT if format detection fails.