The swiss army knife of lossless video/audio editing
Allow disable deletion of merged segments #480
Mikael Finstadf2b44b372620
diff --git a/public/configStore.js b/public/configStore.jsindex 3ac70a3a..d540dd57 100644--- a/public/configStore.js+++ b/public/configStore.js@@ -6,6 +6,7 @@ const defaults = {customOutDir: undefined,keyframeCut: true,autoMerge: false,+ autoDeleteMergedSegments: true,timecodeShowFrames: false,invertCutSegments: false,autoExportExtraStreams: true,diff --git a/src/App.jsx b/src/App.jsxindex 027b152d..9a20560d 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -196,6 +196,8 @@ const App = memo(() => {useEffect(() => safeSetConfig('hideNotifications', hideNotifications), [hideNotifications]);const [autoLoadTimecode, setAutoLoadTimecode] = useState(configStore.get('autoLoadTimecode'));useEffect(() => safeSetConfig('autoLoadTimecode', autoLoadTimecode), [autoLoadTimecode]);+ const [autoDeleteMergedSegments, setAutoDeleteMergedSegments] = useState(configStore.get('autoDeleteMergedSegments'));+ useEffect(() => safeSetConfig('autoDeleteMergedSegments', autoDeleteMergedSegments), [autoDeleteMergedSegments]);useEffect(() => {i18n.changeLanguage(language || fallbackLng).catch(console.error);@@ -1031,6 +1033,7 @@ const App = memo(() => {ffmpegExperimental,preserveMovData,onProgress: setCutProgress,+ autoDeleteMergedSegments,});}@@ -1061,7 +1064,7 @@ const App = memo(() => {setWorking();setCutProgress();}- }, [autoMerge, copyFileStreams, customOutDir, duration, effectiveRotation, exportExtraStreams, ffmpegExperimental, fileFormat, fileFormatData, filePath, handleCutFailed, isCustomFormatSelected, isRotationSet, keyframeCut, mainStreams, nonCopiedExtraStreams, outSegments, outputDir, shortestFlag, working, preserveMovData, avoidNegativeTs, numStreamsToCopy, hideAllNotifications, currentSegIndexSafe]);+ }, [autoMerge, copyFileStreams, customOutDir, duration, effectiveRotation, exportExtraStreams, ffmpegExperimental, fileFormat, fileFormatData, filePath, handleCutFailed, isCustomFormatSelected, isRotationSet, keyframeCut, mainStreams, nonCopiedExtraStreams, outSegments, outputDir, shortestFlag, working, preserveMovData, avoidNegativeTs, numStreamsToCopy, hideAllNotifications, currentSegIndexSafe, autoDeleteMergedSegments]);const capture = useCallback(async () => {if (!filePath || !isDurationValid(duration)) return;@@ -1892,12 +1895,14 @@ const App = memo(() => {setHideNotifications={setHideNotifications}autoLoadTimecode={autoLoadTimecode}setAutoLoadTimecode={setAutoLoadTimecode}+ autoDeleteMergedSegments={autoDeleteMergedSegments}+ setAutoDeleteMergedSegments={setAutoDeleteMergedSegments}AutoExportToggler={AutoExportToggler}renderCaptureFormatButton={renderCaptureFormatButton}onWheelTunerRequested={onWheelTunerRequested}/>- ), [AutoExportToggler, askBeforeClose, autoMerge, autoSaveProjectFile, customOutDir, invertCutSegments, keyframeCut, renderCaptureFormatButton, timecodeShowFrames, changeOutDir, onWheelTunerRequested, language, invertTimelineScroll, ffmpegExperimental, setFfmpegExperimental, enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, hideNotifications, setHideNotifications, autoLoadTimecode, setAutoLoadTimecode]);+ ), [AutoExportToggler, askBeforeClose, autoMerge, autoSaveProjectFile, customOutDir, invertCutSegments, keyframeCut, renderCaptureFormatButton, timecodeShowFrames, changeOutDir, onWheelTunerRequested, language, invertTimelineScroll, ffmpegExperimental, setFfmpegExperimental, enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, hideNotifications, setHideNotifications, autoLoadTimecode, setAutoLoadTimecode, autoDeleteMergedSegments, setAutoDeleteMergedSegments]);useEffect(() => {if (!isStoreBuild) loadMifiLink().then(setMifiLink);diff --git a/src/Settings.jsx b/src/Settings.jsxindex d6d5ae82..0a86439b 100644--- a/src/Settings.jsx+++ b/src/Settings.jsx@@ -9,7 +9,7 @@ const Settings = memo(({AutoExportToggler, renderCaptureFormatButton, onWheelTunerRequested, language, setLanguage,invertTimelineScroll, setInvertTimelineScroll, ffmpegExperimental, setFfmpegExperimental,enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction,- hideNotifications, setHideNotifications, autoLoadTimecode, setAutoLoadTimecode+ hideNotifications, setHideNotifications, autoLoadTimecode, setAutoLoadTimecode, autoDeleteMergedSegments, setAutoDeleteMergedSegments,}) => {const { t } = useTranslation();@@ -72,6 +72,17 @@ const Settings = memo(({</Table.TextCell></Row>+ <Row>+ <KeyCell>{t('Auto delete segment files after merge?')}</KeyCell>+ <Table.TextCell>+ <Checkbox+ label={t('Auto delete segments')}+ checked={autoDeleteMergedSegments}+ onChange={e => setAutoDeleteMergedSegments(e.target.checked)}+ />+ </Table.TextCell>+ </Row>+<Row><KeyCell>{t('Keyframe cut mode')}<br />diff --git a/src/ffmpeg.js b/src/ffmpeg.jsindex 17dd0abc..1c0ab7f5 100644--- a/src/ffmpeg.js+++ b/src/ffmpeg.js@@ -533,13 +533,13 @@ export async function mergeFiles({ paths, outPath, allStreams, outFormat, ffmpegawait transferTimestamps(paths[0], outPath);}-export async function autoMergeSegments({ customOutDir, sourceFile, isCustomFormatSelected, outFormat, segmentPaths, ffmpegExperimental, onProgress, preserveMovData }) {+export async function autoMergeSegments({ customOutDir, sourceFile, isCustomFormatSelected, outFormat, segmentPaths, ffmpegExperimental, onProgress, preserveMovData, autoDeleteMergedSegments }) {const ext = getOutFileExtension({ isCustomFormatSelected, outFormat, filePath: sourceFile });const fileName = `cut-merged-${new Date().getTime()}${ext}`;const outPath = getOutPath(customOutDir, sourceFile, fileName);await mergeFiles({ paths: segmentPaths, outPath, outFormat, allStreams: true, ffmpegExperimental, onProgress, preserveMovData });- await pMap(segmentPaths, path => fs.unlink(path), { concurrency: 5 });+ if (autoDeleteMergedSegments) await pMap(segmentPaths, path => fs.unlink(path), { concurrency: 5 });}/**