The swiss army knife of lossless video/audio editing
improvements
Mikael Finstad479569e37894
diff --git a/public/configStore.js b/public/configStore.jsindex 2d29ad33..e9448442 100644--- a/public/configStore.js+++ b/public/configStore.js@@ -65,7 +65,6 @@ const defaultKeyBindings = [{ keys: 'enter', action: 'labelCurrentSegment' },{ keys: 'e', action: 'export' },- { keys: 'h', action: 'toggleHelp' },{ keys: 'shift+/', action: 'toggleKeyboardShortcuts' },{ keys: 'escape', action: 'closeActiveScreen' },diff --git a/public/menu.js b/public/menu.jsindex 94dec5fd..9c824bac 100644--- a/public/menu.js+++ b/public/menu.js@@ -299,6 +299,10 @@ module.exports = (app, mainWindow, newVersion) => {mainWindow.webContents.send('detectBlackScenes');},},+ {+ label: i18n.t('Last ffmpeg commands'),+ click() { mainWindow.webContents.send('toggleLastCommands'); },+ },{ type: 'separator' },{ role: 'toggleDevTools', label: i18n.t('Toggle Developer Tools') },],@@ -308,29 +312,40 @@ module.exports = (app, mainWindow, newVersion) => {label: i18n.t('Help'),submenu: [{- label: i18n.t('Help and shortcuts'),- click() {- mainWindow.webContents.send('toggleHelp');- },+ label: i18n.t('How to use'),+ click() { electron.shell.openExternal('https://mifi.no/losslesscut/usage'); },},{- label: i18n.t('About'),- click() {- mainWindow.webContents.send('openAbout');- },+ label: i18n.t('FAQ'),+ click() { electron.shell.openExternal('https://mifi.no/losslesscut/faq'); },},{- label: i18n.t('Licenses'),- click() { electron.shell.openExternal(licensesPage); },+ label: i18n.t('Troubleshooting'),+ click() { electron.shell.openExternal('https://mifi.no/losslesscut/troubleshooting'); },},{label: i18n.t('Learn More'),click() { electron.shell.openExternal(homepage); },},+ {+ label: i18n.t('Licenses'),+ click() { electron.shell.openExternal(licensesPage); },+ },+ { type: 'separator' },+ {+ label: i18n.t('Keyboard & mouse shortcuts'.replace(/&/g, '&&')),+ click() {+ mainWindow.webContents.send('toggleKeyboardShortcuts');+ },+ },{label: i18n.t('Report an error'),click() { mainWindow.webContents.send('openSendReportDialog'); },},+ {+ label: i18n.t('Version'),+ click() { mainWindow.webContents.send('openAbout'); },+ },],},];diff --git a/src/App.jsx b/src/App.jsxindex 565cdf1a..ad018c2e 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -3,7 +3,7 @@ import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';import { FaAngleLeft, FaWindowClose } from 'react-icons/fa';import { MdRotate90DegreesCcw } from 'react-icons/md';import { AnimatePresence, motion } from 'framer-motion';-import { Table, SideSheet, Position, ThemeProvider } from 'evergreen-ui';+import { Heading, InlineAlert, Table, SideSheet, Position, ThemeProvider } from 'evergreen-ui';import { useStateWithHistory } from 'react-use/lib/useStateWithHistory';import useDebounceOld from 'react-use/lib/useDebounce'; // Want to phase out thisimport { useDebounce } from 'use-debounce';@@ -31,7 +31,7 @@ import NoFileLoaded from './NoFileLoaded';import Canvas from './Canvas';import TopMenu from './TopMenu';import Sheet from './Sheet';-import HelpSheet from './HelpSheet';+import LastCommandsSheet from './LastCommandsSheet';import StreamsSelector from './StreamsSelector';import SegmentList from './SegmentList';import Settings from './Settings';@@ -148,7 +148,7 @@ const App = memo(() => {const [showRightBar, setShowRightBar] = useState(true);const [cleanupChoices, setCleanupChoices] = useState({ tmpFiles: true });const [rememberConvertToSupportedFormat, setRememberConvertToSupportedFormat] = useState();- const [helpVisible, setHelpVisible] = useState(false);+ const [lastCommandsVisible, setLastCommandsVisible] = useState(false);const [settingsVisible, setSettingsVisible] = useState(false);const [tunerVisible, setTunerVisible] = useState();const [keyboardShortcutsVisible, setKeyboardShortcutsVisible] = useState(false);@@ -1245,10 +1245,11 @@ const App = memo(() => {rotation,shortestFlag,effectiveExportMode,+ outSegTemplate,};openSendReportDialog(err, state);- }, [filePath, fileFormat, externalFilesMeta, mainStreams, copyStreamIdsByFile, cutSegments, mainFileFormatData, rotation, shortestFlag, effectiveExportMode]);+ }, [filePath, fileFormat, externalFilesMeta, mainStreams, copyStreamIdsByFile, cutSegments, mainFileFormatData, rotation, shortestFlag, effectiveExportMode, outSegTemplate]);const handleCutFailed = useCallback(async (err) => {const sendErrorReport = await showCutFailedDialog({ detectedFileFormat });@@ -1619,7 +1620,7 @@ const App = memo(() => {}}, [resetState, setWorking, showPreviewFileLoadedMessage, autoLoadTimecode, html5ifyAndLoadWithPreferences, getEdlFilePath, getEdlFilePathOld, loadEdlFile, enableAskForImportChapters, loadCutSegments, setCopyStreamIdsForPath, setFileFormat, outFormatLocked, setDetectedFileFormat]);- const toggleHelp = useCallback(() => setHelpVisible(val => !val), []);+ const toggleLastCommands = useCallback(() => setLastCommandsVisible(val => !val), []);const toggleSettings = useCallback(() => setSettingsVisible(val => !val), []);const jumpSeg = useCallback((val) => setCurrentSegIndex((old) => Math.max(Math.min(old + val, cutSegments.length - 1), 0)), [cutSegments.length]);@@ -2063,7 +2064,7 @@ const App = memo(() => {redo: () => cutSegmentsHistory.forward(),labelCurrentSegment: () => { onLabelSegment(currentSegIndexSafe); return false; },addSegment,- toggleHelp: () => { toggleHelp(); return false; },+ toggleLastCommands: () => { toggleLastCommands(); return false; },export: onExportPress,extractCurrentSegmentFramesAsImages,reorderSegsByStartTime,@@ -2106,7 +2107,7 @@ const App = memo(() => {// always allowif (action === 'closeActiveScreen') {closeExportConfirm();- setHelpVisible(false);+ setLastCommandsVisible(false);setSettingsVisible(false);return false;}@@ -2133,7 +2134,7 @@ const App = memo(() => {if (match) return bubble;return true; // bubble the event- }, [addSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, captureSnapshotAsCoverArt, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, currentSegIndexSafe, cutSegmentsHistory, deselectAllSegments, exportConfirmVisible, extractAllStreams, extractCurrentSegmentFramesAsImages, fillSegmentsGaps, goToTimecode, increaseRotation, invertAllSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegment, pause, play, removeCutSegment, removeSelectedSegments, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, selectAllSegments, selectOnlyCurrentSegment, setCutEnd, setCutStart, setPlaybackVolume, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentSelected, toggleHelp, toggleKeyboardShortcuts, toggleKeyframeCut, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, tryFixInvalidDuration, userHtml5ifyCurrentFile, zoomRel]);+ }, [addSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, captureSnapshotAsCoverArt, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, currentSegIndexSafe, cutSegmentsHistory, deselectAllSegments, exportConfirmVisible, extractAllStreams, extractCurrentSegmentFramesAsImages, fillSegmentsGaps, goToTimecode, increaseRotation, invertAllSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegment, pause, play, removeCutSegment, removeSelectedSegments, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, selectAllSegments, selectOnlyCurrentSegment, setCutEnd, setCutStart, setPlaybackVolume, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentSelected, toggleKeyboardShortcuts, toggleKeyframeCut, toggleLastCommands, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, tryFixInvalidDuration, userHtml5ifyCurrentFile, zoomRel]);useKeyboard({ keyBindings, onKeyPress });@@ -2249,7 +2250,8 @@ const App = memo(() => {importEdlFile,exportEdlFile: exportEdlFile2,exportEdlYouTube,- toggleHelp,+ toggleLastCommands,+ toggleKeyboardShortcuts,toggleSettings,openAbout,openSendReportDialog: () => { openSendReportDialogWithState(); },@@ -2270,7 +2272,7 @@ const App = memo(() => {const entries = Object.entries(action);entries.forEach(([key, value]) => electron.ipcRenderer.on(key, value));return () => entries.forEach(([key, value]) => electron.ipcRenderer.removeListener(key, value));- }, [apparentCutSegments, askSetStartTimeOffset, checkFileOpened, clearSegments, closeBatch, closeFileWithConfirm, concatCurrentBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, customOutDir, cutSegments, detectBlackScenes, detectedFps, extractAllStreams, fileFormat, filePath, fillSegmentsGaps, getFrameCount, invertAllSegments, loadCutSegments, loadMedia, openFilesDialog, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shiftAllSegmentTimes, shuffleSegments, toggleHelp, toggleSettings, tryFixInvalidDuration, userHtml5ifyCurrentFile, userOpenFiles]);+ }, [apparentCutSegments, askSetStartTimeOffset, checkFileOpened, clearSegments, closeBatch, closeFileWithConfirm, concatCurrentBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, customOutDir, cutSegments, detectBlackScenes, detectedFps, extractAllStreams, fileFormat, filePath, fillSegmentsGaps, getFrameCount, invertAllSegments, loadCutSegments, loadMedia, openFilesDialog, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shiftAllSegmentTimes, shuffleSegments, toggleKeyboardShortcuts, toggleLastCommands, toggleSettings, tryFixInvalidDuration, userHtml5ifyCurrentFile, userOpenFiles]);const showAddStreamSourceDialog = useCallback(async () => {try {@@ -2305,8 +2307,6 @@ const App = memo(() => {setTunerVisible(type);}, []);- const onKeyboardShortcutsDialogRequested = useCallback(() => setKeyboardShortcutsVisible(true), []);-useEffect(() => {if (!isStoreBuild) loadMifiLink().then(setMifiLink);}, []);@@ -2370,7 +2370,6 @@ const App = memo(() => {clearOutDir={clearOutDir}isCustomFormatSelected={isCustomFormatSelected}renderOutFmt={renderOutFmt}- toggleHelp={toggleHelp}toggleSettings={toggleSettings}numStreamsToCopy={numStreamsToCopy}numStreamsTotal={numStreamsTotal}@@ -2398,7 +2397,7 @@ const App = memo(() => {{/* Middle part: */}<div style={{ position: 'relative', flexGrow: 1, overflow: 'hidden' }}>- {!isFileOpened && <NoFileLoaded mifiLink={mifiLink} toggleHelp={toggleHelp} currentCutSeg={currentCutSeg} />}+ {!isFileOpened && <NoFileLoaded mifiLink={mifiLink} currentCutSeg={currentCutSeg} />}<div className="no-user-select" style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, visibility: !isFileOpened ? 'hidden' : undefined }} onWheel={onTimelineWheel}>{/* eslint-disable-next-line jsx-a11y/media-has-caption */}@@ -2598,15 +2597,16 @@ const App = memo(() => {<ExportConfirm filePath={filePath} areWeCutting={areWeCutting} nonFilteredSegments={nonFilteredSegments} selectedSegments={selectedSegmentsOrInverse} segmentsToExport={segmentsToExport} willMerge={willMerge} visible={exportConfirmVisible} onClosePress={closeExportConfirm} onExportConfirm={onExportConfirm} renderOutFmt={renderOutFmt} outputDir={outputDir} numStreamsTotal={numStreamsTotal} numStreamsToCopy={numStreamsToCopy} setStreamsSelectorShown={setStreamsSelectorShown} outFormat={fileFormat} setOutSegTemplate={setOutSegTemplate} outSegTemplate={outSegTemplateOrDefault} generateOutSegFileNames={generateOutSegFileNames} currentSegIndexSafe={currentSegIndexSafe} getOutSegError={getOutSegError} />- <HelpSheet- visible={helpVisible}- onTogglePress={toggleHelp}+ <LastCommandsSheet+ visible={lastCommandsVisible}+ onTogglePress={toggleLastCommands}ffmpegCommandLog={ffmpegCommandLog}- onKeyboardShortcutsDialogRequested={onKeyboardShortcutsDialogRequested}/><Sheet visible={settingsVisible} onClosePress={toggleSettings} style={{ background: 'white', color: 'black' }}>- <Table style={{ marginTop: 40 }}>+ <Heading>{t('Keyboard & mouse shortcuts')}</Heading>+ <InlineAlert marginTop={20}>{t('Hover mouse over buttons in the main interface to see which function they have')}</InlineAlert>+ <Table style={{ marginTop: 20 }}><Table.Head><Table.TextHeaderCell>{t('Settings')}</Table.TextHeaderCell><Table.TextHeaderCell>{t('Current setting')}</Table.TextHeaderCell>@@ -2614,7 +2614,7 @@ const App = memo(() => {<Table.Body><SettingsonTunerRequested={onTunerRequested}- onKeyboardShortcutsDialogRequested={onKeyboardShortcutsDialogRequested}+ onKeyboardShortcutsDialogRequested={toggleKeyboardShortcuts}/></Table.Body></Table>diff --git a/src/HelpSheet.jsx b/src/HelpSheet.jsxdeleted file mode 100644index e1b64b0f..00000000--- a/src/HelpSheet.jsx+++ /dev/null@@ -1,59 +0,0 @@-import React, { memo } from 'react';-import { FaKeyboard } from 'react-icons/fa';-import { useTranslation, Trans } from 'react-i18next';-import { Button } from 'evergreen-ui';--import CopyClipboardButton from './components/CopyClipboardButton';-import { primaryTextColor } from './colors';-import Sheet from './Sheet';--const electron = window.require('electron');--const { githubLink } = electron.remote.require('./constants');--const HelpSheet = memo(({ visible, onTogglePress, ffmpegCommandLog, onKeyboardShortcutsDialogRequested }) => {- const { t } = useTranslation();-- return (- <Sheet visible={visible} onClosePress={onTogglePress} style={{ background: '#6b6b6b', color: 'white' }}>- <div className="help-sheet">- <h1>{t('Common problems')}</h1>- <p>- {t('Lossless cutting is not an exact science. For some codecs and files it just works. For others you may need to trial and error depending on the codec, keyframes etc to get the best cut.')}- </p>- <ol>- <li><Trans>Try both <b>Normal cut</b> and <b>Keyframe cut</b></Trans></li>- <li><Trans>Try to set the <b>start-</b>cutpoint a <b>few frames before or after</b> the nearest keyframe (may also solve audio sync issues)</Trans></li>- <li><Trans>Disable unnecessary <b>Tracks</b></Trans></li>- <li><Trans>Select a different output <b>Format</b> (<b>matroska</b> and <b>mp4</b> support most codecs)</Trans></li>- <li><Trans>Try to enable the <b>Experimental Flag</b> in Settings</Trans></li>- </ol>-- <p style={{ fontWeight: 'bold' }}>- {t('For more help and issues, please go to:')}<br />- <span style={{ color: primaryTextColor, cursor: 'pointer' }} role="button" onClick={() => electron.shell.openExternal(githubLink)}>{githubLink}</span>- </p>-- <Button iconBefore={<FaKeyboard />} onClick={onKeyboardShortcutsDialogRequested}>{t('Keyboard & mouse shortcuts')}</Button>-- <p style={{ fontWeight: 'bold' }}>{t('Hover mouse over buttons in the main interface to see which function they have')}</p>-- <h1 style={{ marginTop: 40 }}>{t('Last ffmpeg commands')}</h1>- {ffmpegCommandLog.length > 0 ? (- <div style={{ overflowY: 'scroll', height: 200 }}>- {ffmpegCommandLog.reverse().map(({ command }, i) => (- // eslint-disable-next-line react/no-array-index-key- <div key={i} style={{ whiteSpace: 'pre', margin: '5px 0' }}>- <CopyClipboardButton text={command} /> {command}- </div>- ))}- </div>- ) : (- <p>{t('The last executed ffmpeg commands will show up here after you run operations. You can copy them to clipboard and modify them to your needs before running on your command line.')}</p>- )}- </div>- </Sheet>- );-});--export default HelpSheet;diff --git a/src/LastCommandsSheet.jsx b/src/LastCommandsSheet.jsxnew file mode 100644index 00000000..20cbceca--- /dev/null+++ b/src/LastCommandsSheet.jsx@@ -0,0 +1,31 @@+import React, { memo } from 'react';+import { useTranslation } from 'react-i18next';+import { Heading } from 'evergreen-ui';++import CopyClipboardButton from './components/CopyClipboardButton';+import Sheet from './Sheet';++const LastCommandsSheet = memo(({ visible, onTogglePress, ffmpegCommandLog }) => {+ const { t } = useTranslation();++ return (+ <Sheet visible={visible} onClosePress={onTogglePress} style={{ background: '#6b6b6b', color: 'white' }}>+ <Heading color="white">{t('Last ffmpeg commands')}</Heading>++ {ffmpegCommandLog.length > 0 ? (+ <div>+ {ffmpegCommandLog.reverse().map(({ command }, i) => (+ // eslint-disable-next-line react/no-array-index-key+ <div key={i} style={{ whiteSpace: 'pre', margin: '5px 0' }}>+ <CopyClipboardButton text={command} /> {command}+ </div>+ ))}+ </div>+ ) : (+ <p>{t('The last executed ffmpeg commands will show up here after you run operations. You can copy them to clipboard and modify them to your needs before running on your command line.')}</p>+ )}+ </Sheet>+ );+});++export default LastCommandsSheet;diff --git a/src/NoFileLoaded.jsx b/src/NoFileLoaded.jsxindex 82abba80..98af726b 100644--- a/src/NoFileLoaded.jsx+++ b/src/NoFileLoaded.jsx@@ -9,7 +9,7 @@ import useUserSettings from './hooks/useUserSettings';const electron = window.require('electron');-const NoFileLoaded = memo(({ mifiLink, toggleHelp, currentCutSeg }) => {+const NoFileLoaded = memo(({ mifiLink, currentCutSeg }) => {const { t } = useTranslation();const { simpleMode, toggleSimpleMode } = useUserSettings();@@ -17,8 +17,8 @@ const NoFileLoaded = memo(({ mifiLink, toggleHelp, currentCutSeg }) => {<div className="no-user-select" style={{ position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, border: '2vmin dashed #252525', color: '#505050', margin: '5vmin', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', whiteSpace: 'nowrap' }}><div style={{ fontSize: '6vmin', textTransform: 'uppercase' }}>{t('DROP FILE(S)')}</div>- <div style={{ fontSize: '4vmin', color: '#777', cursor: 'pointer' }} role="button" onClick={toggleHelp}>- <Trans>Press <kbd>H</kbd> for help</Trans>+ <div style={{ fontSize: '3vmin', color: '#777', marginBottom: '.3em' }}>+ <Trans>See <b>Help</b> menu for help</Trans></div><div style={{ fontSize: '3vmin', color: '#ccc' }}>diff --git a/src/TopMenu.jsx b/src/TopMenu.jsxindex c2594c8f..3bcaddc7 100644--- a/src/TopMenu.jsx+++ b/src/TopMenu.jsx@@ -1,5 +1,5 @@import React, { memo, useCallback } from 'react';-import { IoIosHelpCircle, IoIosSettings } from 'react-icons/io';+import { IoIosSettings } from 'react-icons/io';import { FaLock, FaUnlock } from 'react-icons/fa';import { IconButton, Button, CrossIcon, ListIcon, VolumeUpIcon, VolumeOffIcon } from 'evergreen-ui';import { useTranslation } from 'react-i18next';@@ -13,7 +13,7 @@ import useUserSettings from './hooks/useUserSettings';const TopMenu = memo(({filePath, fileFormat, copyAnyAudioTrack, toggleStripAudio,- renderOutFmt, toggleHelp, numStreamsToCopy, numStreamsTotal, setStreamsSelectorShown, toggleSettings,+ renderOutFmt, numStreamsToCopy, numStreamsTotal, setStreamsSelectorShown, toggleSettings,selectedSegments, isCustomFormatSelected, clearOutDir,}) => {const { t } = useTranslation();@@ -82,7 +82,6 @@ const TopMenu = memo(({</>)}- <IoIosHelpCircle size={24} role="button" onClick={toggleHelp} style={{ verticalAlign: 'middle', marginLeft: 5 }} /><IoIosSettings size={24} role="button" onClick={toggleSettings} style={{ verticalAlign: 'middle', marginLeft: 5 }} /></div>);diff --git a/src/components/KeyboardShortcuts.jsx b/src/components/KeyboardShortcuts.jsxindex c7c065fa..8858827e 100644--- a/src/components/KeyboardShortcuts.jsx+++ b/src/components/KeyboardShortcuts.jsx@@ -140,8 +140,8 @@ const KeyboardShortcuts = memo(({],},actionsMap: {- toggleHelp: {- name: t('Show/hide help screen'),+ toggleLastCommands: {+ name: t('Last ffmpeg commands'),},toggleKeyboardShortcuts: {name: t('Keyboard & mouse shortcuts'),diff --git a/src/dialogs.jsx b/src/dialogs.jsxindex 0c7c9c4b..a6272f50 100644--- a/src/dialogs.jsx+++ b/src/dialogs.jsx@@ -445,7 +445,7 @@ export async function showCutFailedDialog({ detectedFileFormat }) {<li><Trans>Try both <b>Normal cut</b> and <b>Keyframe cut</b></Trans></li><li><Trans>Set a different <b>Working directory</b></Trans></li><li><Trans>Try with a <b>Different file</b></Trans></li>- <li><Trans>See <b>Help</b></Trans></li>+ <li><Trans>See <b>Help</b></Trans> menu</li><li><Trans>If nothing helps, you can send an <b>Error report</b></Trans></li></ol></div>diff --git a/src/main.css b/src/main.cssindex dae400c3..da75252c 100644--- a/src/main.css+++ b/src/main.css@@ -19,19 +19,6 @@ body {cursor: default;}-.help-sheet h1 {- font-size: 1.2em;- margin-bottom: .5em;- margin-top: 1.3em;- text-transform: uppercase;-}--.help-sheet h2 {- font-size: 1em;- margin-bottom: .5em;- text-transform: uppercase;-}-kbd {display: inline-block;padding: 3px 5px;