The swiss army knife of lossless video/audio editing
always save llc inside source directory
Mikael Finstad5534574df719
diff --git a/src/App.jsx b/src/App.jsxindex 1490eef5..96143b5b 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -523,9 +523,10 @@ const App = memo(() => {const projectSuffix = 'proj.llc';const oldProjectSuffix = 'llc-edl.csv';- const getEdlFilePath = useCallback((fp) => getOutPath(customOutDir, fp, projectSuffix), [customOutDir]);- // Old versions of LosslessCut used CSV files:- const getEdlFilePathOld = useCallback((fp) => getOutPath(customOutDir, fp, oldProjectSuffix), [customOutDir]);+ // New LLC format is stored along with input file https://github.com/mifi/lossless-cut/issues/905+ const getEdlFilePath = useCallback((fp) => getOutPath({ filePath: fp, nameSuffix: projectSuffix }), []);+ // Old versions of LosslessCut used CSV files and stored them in customOutDir:+ const getEdlFilePathOld = useCallback((fp) => getOutPath({ customOutDir, filePath: fp, nameSuffix: oldProjectSuffix }), [customOutDir]);const edlFilePath = useMemo(() => getEdlFilePath(filePath), [getEdlFilePath, filePath]);const currentSaveOperation = useMemo(() => {@@ -632,7 +633,7 @@ const App = memo(() => {if (cancel) return;const ext = extname(firstPath);- const outPath = getOutPath(newCustomOutDir, firstPath, `merged${ext}`);+ const outPath = getOutPath({ customOutDir: newCustomOutDir, filePath: firstPath, nameSuffix: `merged${ext}` });const outDir = getOutDir(customOutDir, firstPath);let chapters;@@ -896,7 +897,7 @@ const App = memo(() => {async function doHtml5ify() {if (speed === 'fastest') {- const path = getOutPath(cod, fp, `${html5ifiedPrefix}${html5dummySuffix}.mkv`);+ const path = getOutPath({ customOutDir: cod, filePath: fp, nameSuffix: `${html5ifiedPrefix}${html5dummySuffix}.mkv` });try {setCutProgress(0);await html5ifyDummy({ filePath: fp, outPath: path, onProgress: setCutProgress });diff --git a/src/Settings.jsx b/src/Settings.jsxindex 1590ae61..325e3960 100644--- a/src/Settings.jsx+++ b/src/Settings.jsx@@ -82,7 +82,7 @@ const Settings = memo(({<Row><KeyCell>{t('Working directory')}<br />- {t('This is where working files, exported files, project files (LLC) are stored.')}+ {t('This is where working files and exported files are stored.')}</KeyCell><Table.TextCell><Button iconBefore={customOutDir ? FolderCloseIcon : DocumentIcon} onClick={changeOutDir}>@@ -151,7 +151,7 @@ const Settings = memo(({<Row><KeyCell>{t('Auto save project file?')}<br />- {t('The project will be stored alongside the output files as a project LLC file')}+ {t('The project will be stored alongside the input file as a project LLC file')}</KeyCell><Table.TextCell><Checkboxdiff --git a/src/capture-frame.js b/src/capture-frame.jsindex 1f9ccc83..aebb24b0 100644--- a/src/capture-frame.js+++ b/src/capture-frame.js@@ -23,7 +23,7 @@ function getFrameFromVideo(video, format) {export async function captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, enableTransferTimestamps }) {const time = formatDuration({ seconds: currentTime, fileNameFriendly: true });- const outPath = getOutPath(customOutDir, filePath, `${time}.${captureFormat}`);+ const outPath = getOutPath({ customOutDir, filePath, nameSuffix: `${time}.${captureFormat}` });await ffmpegCaptureFrame({ timestamp: currentTime, videoPath: filePath, outPath });if (enableTransferTimestamps) await transferTimestamps(filePath, outPath, currentTime);@@ -36,7 +36,7 @@ export async function captureFrameFromTag({ customOutDir, filePath, currentTime,const ext = mime.extension(buf.mimetype);const time = formatDuration({ seconds: currentTime, fileNameFriendly: true });- const outPath = getOutPath(customOutDir, filePath, `${time}.${ext}`);+ const outPath = getOutPath({ customOutDir, filePath, nameSuffix: `${time}.${ext}` });await fs.writeFile(outPath, buf);if (enableTransferTimestamps) await transferTimestamps(filePath, outPath, currentTime);diff --git a/src/ffmpeg.js b/src/ffmpeg.jsindex 56381e51..ef9c0b0b 100644--- a/src/ffmpeg.js+++ b/src/ffmpeg.js@@ -314,7 +314,7 @@ async function extractNonAttachmentStreams({ customOutDir, filePath, streams })console.log('Extracting', streams.length, 'normal streams');const streamArgs = flatMap(streams, ({ index, codec, type, format: { format, ext } }) => [- '-map', `0:${index}`, '-c', 'copy', '-f', format, '-y', getOutPath(customOutDir, filePath, `stream-${index}-${type}-${codec}.${ext}`),+ '-map', `0:${index}`, '-c', 'copy', '-f', format, '-y', getOutPath({ customOutDir, filePath, nameSuffix: `stream-${index}-${type}-${codec}.${ext}` }),]);const ffmpegArgs = [@@ -336,7 +336,7 @@ async function extractAttachmentStreams({ customOutDir, filePath, streams }) {const streamArgs = flatMap(streams, ({ index, codec_name: codec, codec_type: type }) => {const ext = codec || 'bin';return [- `-dump_attachment:${index}`, getOutPath(customOutDir, filePath, `stream-${index}-${type}-${codec}.${ext}`),+ `-dump_attachment:${index}`, getOutPath({ customOutDir, filePath, nameSuffix: `stream-${index}-${type}-${codec}.${ext}` }),];});diff --git a/src/hooks/useFfmpegOperations.js b/src/hooks/useFfmpegOperations.jsindex 6201839f..1d09be61 100644--- a/src/hooks/useFfmpegOperations.js+++ b/src/hooks/useFfmpegOperations.js@@ -274,8 +274,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {const autoMergeSegments = useCallback(async ({ customOutDir, isCustomFormatSelected, outFormat, segmentPaths, ffmpegExperimental, onProgress, preserveMovData, movFastStart, autoDeleteMergedSegments, chapterNames, preserveMetadataOnMerge }) => {const ext = getOutFileExtension({ isCustomFormatSelected, outFormat, filePath });- const fileName = `cut-merged-${new Date().getTime()}${ext}`;- const outPath = getOutPath(customOutDir, filePath, fileName);+ const outPath = getOutPath({ customOutDir, filePath, nameSuffix: `cut-merged-${new Date().getTime()}${ext}` });const outDir = getOutDir(customOutDir, filePath);const chapters = await createChaptersFromSegments({ segmentPaths, chapterNames });@@ -404,8 +403,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {// https://stackoverflow.com/questions/34118013/how-to-determine-webm-duration-using-ffprobeconst fixInvalidDuration = useCallback(async ({ fileFormat, customOutDir }) => {const ext = getOutFileExtension({ outFormat: fileFormat, filePath });- const fileName = `reformatted${ext}`;- const outPath = getOutPath(customOutDir, filePath, fileName);+ const outPath = getOutPath({ customOutDir, filePath, nameSuffix: `reformatted${ext}` });const ffmpegArgs = ['-hide_banner',diff --git a/src/util.js b/src/util.jsindex 110d7735..bfd5db70 100644--- a/src/util.js+++ b/src/util.js@@ -23,7 +23,7 @@ export function getFileBaseName(filePath) {return parsed.name;}-export function getOutPath(customOutDir, filePath, nameSuffix) {+export function getOutPath({ customOutDir, filePath, nameSuffix }) {if (!filePath) return undefined;return join(getOutDir(customOutDir, filePath), `${getFileBaseName(filePath)}-${nameSuffix}`);}@@ -238,7 +238,7 @@ export async function findExistingHtml5FriendlyFile(fp, cod) {export function getHtml5ifiedPath(cod, fp, type) {// See also inside ffmpegHtml5ifyconst ext = (isMac && ['slowest', 'slow', 'slow-audio'].includes(type)) ? 'mp4' : 'mkv';- return getOutPath(cod, fp, `${html5ifiedPrefix}${type}.${ext}`);+ return getOutPath({ customOutDir: cod, filePath: fp, nameSuffix: `${html5ifiedPrefix}${type}.${ext}` });}export async function deleteFiles({ toDelete, paths: { previewFilePath, filePath, edlFilePath } }) {