The swiss army knife of lossless video/audio editing
Implement export single #358
Mikael Finstad052d6c33f3d0
diff --git a/src/App.jsx b/src/App.jsxindex 4d5b1a85..4e234cf7 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -985,7 +985,7 @@ const App = memo(() => {const closeExportConfirm = useCallback(() => setExportConfirmVisible(false), []);- const onExportConfirmPress = useCallback(async () => {+ const onExportConfirm = useCallback(async ({ exportSingle } = {}) => {if (working) return;if (numStreamsToCopy === 0) {@@ -995,6 +995,8 @@ const App = memo(() => {setExportConfirmVisible(false);+ const filteredOutSegments = exportSingle ? [outSegments[currentSegIndexSafe]] : outSegments;+try {setWorking(i18n.t('Exporting'));@@ -1008,7 +1010,7 @@ const App = memo(() => {rotation: isRotationSet ? effectiveRotation : undefined,copyFileStreams,keyframeCut,- segments: outSegments,+ segments: filteredOutSegments,onProgress: setCutProgress,appendFfmpegCommandLog,shortestFlag,@@ -1033,11 +1035,9 @@ const App = memo(() => {});}- if (exportExtraStreams) {+ if (exportExtraStreams && !exportSingle) {try {- await extractStreams({- filePath, customOutDir, streams: nonCopiedExtraStreams,- });+ await extractStreams({ filePath, customOutDir, streams: nonCopiedExtraStreams });} catch (err) {console.error('Extra stream export failed', err);}@@ -1062,7 +1062,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]);+ }, [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]);const capture = useCallback(async () => {if (!filePath || !isDurationValid(duration)) return;@@ -1371,7 +1371,7 @@ const App = memo(() => {useEffect(() => {function onExportPress2() {- if (exportConfirmVisible) onExportConfirmPress();+ if (exportConfirmVisible) onExportConfirm();else onExportPress();}@@ -1380,7 +1380,7 @@ const App = memo(() => {return () => {hotkeys.unbind('e', onExportPress2);};- }, [exportConfirmVisible, onExportConfirmPress, onExportPress]);+ }, [exportConfirmVisible, onExportConfirm, onExportPress]);useEffect(() => {function onEscPress() {@@ -2189,7 +2189,7 @@ const App = memo(() => {</div></motion.div>- <ExportConfirm autoMerge={autoMerge} toggleAutoMerge={toggleAutoMerge} areWeCutting={areWeCutting} outSegments={outSegments} visible={exportConfirmVisible} onClosePress={closeExportConfirm} onCutPress={onExportConfirmPress} keyframeCut={keyframeCut} toggleKeyframeCut={toggleKeyframeCut} renderOutFmt={renderOutFmt} preserveMovData={preserveMovData} togglePreserveMovData={togglePreserveMovData} avoidNegativeTs={avoidNegativeTs} setAvoidNegativeTs={setAvoidNegativeTs} changeOutDir={changeOutDir} outputDir={outputDir} numStreamsTotal={numStreamsTotal} numStreamsToCopy={numStreamsToCopy} setStreamsSelectorShown={setStreamsSelectorShown} />+ <ExportConfirm autoMerge={autoMerge} toggleAutoMerge={toggleAutoMerge} areWeCutting={areWeCutting} outSegments={outSegments} visible={exportConfirmVisible} onClosePress={closeExportConfirm} onExportConfirm={onExportConfirm} keyframeCut={keyframeCut} toggleKeyframeCut={toggleKeyframeCut} renderOutFmt={renderOutFmt} preserveMovData={preserveMovData} togglePreserveMovData={togglePreserveMovData} avoidNegativeTs={avoidNegativeTs} setAvoidNegativeTs={setAvoidNegativeTs} changeOutDir={changeOutDir} outputDir={outputDir} numStreamsTotal={numStreamsTotal} numStreamsToCopy={numStreamsToCopy} setStreamsSelectorShown={setStreamsSelectorShown} currentSegIndex={currentSegIndexSafe} invertCutSegments={invertCutSegments} /><HelpSheetvisible={helpVisible}diff --git a/src/ExportConfirm.jsx b/src/ExportConfirm.jsxindex 5481d1b7..cb3213ce 100644--- a/src/ExportConfirm.jsx+++ b/src/ExportConfirm.jsx@@ -4,6 +4,7 @@ import { Button, Select } from 'evergreen-ui';import i18n from 'i18next';import { useTranslation, Trans } from 'react-i18next';import { IoIosHelpCircle } from 'react-icons/io';+import { FiScissors } from 'react-icons/fi';import KeyframeCutButton from './components/KeyframeCutButton';import ExportButton from './components/ExportButton';@@ -11,6 +12,7 @@ import MergeExportButton from './components/MergeExportButton';import PreserveMovDataButton from './components/PreserveMovDataButton';import { withBlur, toast } from './util';+import { primaryColor } from './colors';const sheetStyle = {position: 'fixed',@@ -34,9 +36,9 @@ const Highlight = ({ children, style, ...props }) => <span {...props} style={{ bconst HelpIcon = ({ onClick }) => <IoIosHelpCircle size={20} role="button" onClick={withBlur(onClick)} style={{ verticalAlign: 'middle', marginLeft: 5 }} />;const ExportConfirm = memo(({- autoMerge, areWeCutting, outSegments, visible, onClosePress, onCutPress, keyframeCut, toggleKeyframeCut,+ autoMerge, areWeCutting, outSegments, visible, onClosePress, onExportConfirm, keyframeCut, toggleKeyframeCut,toggleAutoMerge, renderOutFmt, preserveMovData, togglePreserveMovData, avoidNegativeTs, setAvoidNegativeTs,- changeOutDir, outputDir, numStreamsTotal, numStreamsToCopy, setStreamsSelectorShown,+ changeOutDir, outputDir, numStreamsTotal, numStreamsToCopy, setStreamsSelectorShown, currentSegIndex, invertCutSegments,}) => {const { t } = useTranslation();@@ -133,10 +135,18 @@ const ExportConfirm = memo(({animate={{ opacity: 1 }}exit={{ opacity: 0 }}transition={{ duration: 0.4, easings: ['easeOut'] }}+ style={{ display: 'flex', alignItems: 'center' }}>- <Button iconBefore="arrow-left" height={30} onClick={onClosePress} style={{ marginRight: 10 }}>+ <Button iconBefore="arrow-left" height={24} onClick={onClosePress} style={{ marginRight: 10 }}>{i18n.t('Back')}</Button>++ {outSegments.length > 1 && !invertCutSegments && (+ <div role="button" title={t('Export only the currently selected segment ({{segNum}})', { segNum: currentSegIndex + 1 })} onClick={() => onExportConfirm({ exportSingle: true })} style={{ cursor: 'pointer', background: primaryColor, borderRadius: 5, padding: '3px 10px', fontSize: 13, marginRight: 10 }}>+ <FiScissors style={{ verticalAlign: 'middle', marginRight: 6 }} size={16} />+ {t('Export single')}+ </div>+ )}</motion.div><motion.div@@ -146,7 +156,7 @@ const ExportConfirm = memo(({exit={{ scale: 0.5, opacity: 0 }}transition={{ duration: 0.4, easings: ['easeOut'] }}>- <ExportButton outSegments={outSegments} areWeCutting={areWeCutting} autoMerge={autoMerge} onClick={onCutPress} size={1.8} />+ <ExportButton outSegments={outSegments} areWeCutting={areWeCutting} autoMerge={autoMerge} onClick={() => onExportConfirm()} size={1.8} /></motion.div></div></>