The swiss army knife of lossless video/audio editing
improve no file loaded keys
Mikael Finstadb53b0cf867f1
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex 64c79634..350bb2b9 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -89,7 +89,7 @@ import BigWaveform from './components/BigWaveform';import isDev from './isDev';import { BatchFile, Chapter, CustomTagsByFile, EdlExportType, EdlFileType, EdlImportType, FfmpegCommandLog, FilesMeta, goToTimecodeDirectArgsSchema, openFilesActionArgsSchema, ParamsByStreamId, PlaybackMode, SegmentBase, SegmentColorIndex, SegmentTags, SegmentToExport, StateSegment, TunerType } from './types';-import { CaptureFormat, KeyboardAction, Html5ifyMode, WaveformMode, ApiActionRequest } from '../../../types';+import { CaptureFormat, KeyboardAction, Html5ifyMode, WaveformMode, ApiActionRequest, KeyBinding } from '../../../types';import { FFprobeChapter, FFprobeFormat, FFprobeStream } from '../../../ffprobe';import useLoading from './hooks/useLoading';import useVideo from './hooks/useVideo';@@ -178,6 +178,9 @@ function App() {captureFormat, setCaptureFormat, customOutDir, setCustomOutDir, keyframeCut, setKeyframeCut, preserveMetadata, preserveChapters, preserveMovData, movFastStart, avoidNegativeTs, autoMerge, timecodeFormat, invertCutSegments, setInvertCutSegments, autoExportExtraStreams, askBeforeClose, enableAskForImportChapters, enableAskForFileOpenAction, playbackVolume, setPlaybackVolume, autoSaveProjectFile, wheelSensitivity, waveformHeight, invertTimelineScroll, language, ffmpegExperimental, hideNotifications, hideOsNotifications, autoLoadTimecode, autoDeleteMergedSegments, exportConfirmEnabled, setExportConfirmEnabled, segmentsToChapters, preserveMetadataOnMerge, simpleMode, setSimpleMode, outSegTemplate, setOutSegTemplate, mergedFileTemplate, setMergedFileTemplate, keyboardSeekAccFactor, keyboardNormalSeekSpeed, keyboardSeekSpeed2, keyboardSeekSpeed3, treatInputFileModifiedTimeAsStart, treatOutputFileModifiedTimeAsStart, outFormatLocked, setOutFormatLocked, safeOutputFileName, setSafeOutputFileName, enableAutoHtml5ify, segmentsToChaptersOnly, keyBindings, setKeyBindings, resetKeyBindings, enableSmartCut, customFfPath, storeProjectInWorkingDir, setStoreProjectInWorkingDir, enableOverwriteOutput, mouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, captureFrameMethod, captureFrameQuality, captureFrameFileNameFormat, enableNativeHevc, cleanupChoices, setCleanupChoices, darkMode, setDarkMode, preferStrongColors, outputFileNameMinZeroPadding, cutFromAdjustmentFrames, cutToAdjustmentFrames,} = allUserSettings;+ // Note that each action may be multiple key bindings and this will only be the first binding for each action+ const keyBindingByAction = useMemo(() => Object.fromEntries(keyBindings.map((binding) => [binding.action, binding])) as Record<KeyboardAction, KeyBinding>, [keyBindings]);+const { working, setWorking, workingRef, abortWorking } = useLoading();const { videoRef, videoContainerRef, playbackRate, setPlaybackRate, outputPlaybackRate, setOutputPlaybackRate, commandedTime, seekAbs, playingRef, getRelevantTime, setPlaying, onSeeked, relevantTime, onStartPlaying, setCommandedTime, setCompatPlayerEventId, compatPlayerEventId, setOutputPlaybackRateState, commandedTimeRef, onStopPlaying, onVideoAbort, playerTime, setPlayerTime, playbackModeRef, playing, play, pause, seekRel } = useVideo({ filePath });const { timecodePlaceholder, formatTimecode, formatTimeAndFrames, parseTimecode, getFrameCount } = useTimecode({ detectedFps, timecodeFormat });@@ -2479,7 +2482,7 @@ function App() {{/* Middle part (also shown in fullscreen): */}<div style={{ position: 'relative', flexGrow: 1, overflow: 'hidden' }} ref={videoContainerRef}>- {!isFileOpened && <NoFileLoaded mifiLink={mifiLink} currentCutSeg={currentCutSeg} onClick={openFilesDialog} darkMode={darkMode} />}+ {!isFileOpened && <NoFileLoaded mifiLink={mifiLink} currentCutSeg={currentCutSeg} onClick={openFilesDialog} darkMode={darkMode} keyBindingByAction={keyBindingByAction} />}<div className="no-user-select" style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, visibility: !isFileOpened || !hasVideo || bigWaveformEnabled ? 'hidden' : undefined }} onWheel={onTimelineWheel}>{/* eslint-disable-next-line jsx-a11y/media-has-caption */}diff --git a/src/renderer/src/NoFileLoaded.tsx b/src/renderer/src/NoFileLoaded.tsxindex 7c229a68..339dd64d 100644--- a/src/renderer/src/NoFileLoaded.tsx+++ b/src/renderer/src/NoFileLoaded.tsx@@ -1,4 +1,4 @@-import { memo, useMemo } from 'react';+import { Fragment, memo, useMemo } from 'react';import { useTranslation, Trans } from 'react-i18next';@@ -6,14 +6,24 @@ import SetCutpointButton from './components/SetCutpointButton';import SimpleModeButton from './components/SimpleModeButton';import useUserSettings from './hooks/useUserSettings';import { StateSegment } from './types';+import { KeyBinding, KeyboardAction } from '../../../types';+import { splitKeyboardKeys } from './util';const electron = window.require('electron');-function NoFileLoaded({ mifiLink, currentCutSeg, onClick, darkMode }: {+function Keys({ keys }: { keys: string }) {+ const split = splitKeyboardKeys(keys);+ return split.map((key, i) => (+ <Fragment key={key}><kbd>{key.toUpperCase()}</kbd>{i < split.length - 1 && <span style={{ fontSize: '.7em', marginLeft: '-.2em', marginRight: '-.2em' }}>{' + '}</span>}</Fragment>+ ));+}++function NoFileLoaded({ mifiLink, currentCutSeg, onClick, darkMode, keyBindingByAction }: {mifiLink: unknown,currentCutSeg: StateSegment | undefined,onClick: () => void,darkMode?: boolean,+ keyBindingByAction: Record<KeyboardAction, KeyBinding>,}) {const { t } = useTranslation();const { simpleMode } = useUserSettings();@@ -34,7 +44,7 @@ function NoFileLoaded({ mifiLink, currentCutSeg, onClick, darkMode }: {</div><div style={{ fontSize: '1.3em', color: 'var(--gray11)' }}>- <Trans><SetCutpointButton currentCutSeg={currentCutSegOrDefault} side="start" style={{ verticalAlign: 'middle' }} /> <SetCutpointButton currentCutSeg={currentCutSegOrDefault} side="end" style={{ verticalAlign: 'middle' }} /> or <kbd>I</kbd> <kbd>O</kbd> to set cutpoints</Trans>+ <Trans><SetCutpointButton currentCutSeg={currentCutSegOrDefault} side="start" style={{ verticalAlign: 'middle' }} /> <SetCutpointButton currentCutSeg={currentCutSegOrDefault} side="end" style={{ verticalAlign: 'middle' }} /> or <Keys keys={keyBindingByAction.setCutStart.keys} /> <Keys keys={keyBindingByAction.setCutEnd.keys} /> to set cutpoints</Trans></div><div style={{ fontSize: '1.3em', color: 'var(--gray11)' }} role="button" onClick={(e) => e.stopPropagation()}>diff --git a/src/renderer/src/components/KeyboardShortcuts.tsx b/src/renderer/src/components/KeyboardShortcuts.tsxindex 26c0b7ce..05b17428 100644--- a/src/renderer/src/components/KeyboardShortcuts.tsx+++ b/src/renderer/src/components/KeyboardShortcuts.tsx@@ -15,12 +15,14 @@ import { getModifier } from '../hooks/useTimelineScroll';import { KeyBinding, KeyboardAction, ModifierKey } from '../../../../types';import { StateSegment } from '../types';import Sheet from './Sheet';+import { splitKeyboardKeys } from '../util';type Category = string;type ActionsMap = Record<KeyboardAction, { name: string, category?: Category, before?: ReactNode }>;+const renderKeys = (keys: string[]) => keys.map((key, i) => (<Fragment key={key}>{i > 0 && <FaPlus style={{ fontSize: '.4em', opacity: 0.8, marginLeft: '.4em', marginRight: '.4em' }} />}@@ -813,7 +815,7 @@ const KeyboardShortcuts = memo(({<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-end' }}>{bindingsForThisAction.map(({ keys }) => (<div key={keys} style={{ display: 'flex', alignItems: 'center' }}>- {renderKeys(keys.split('+'))}+ {renderKeys(splitKeyboardKeys(keys))}<IconButton title={t('Remove key binding')} appearance="minimal" intent="danger" icon={DeleteIcon} onClick={() => onDeleteBindingClick({ action, keys })} /></div>diff --git a/src/renderer/src/util.ts b/src/renderer/src/util.tsindex b5c75c7a..f00ce8ba 100644--- a/src/renderer/src/util.ts+++ b/src/renderer/src/util.ts@@ -391,7 +391,7 @@ export async function checkAppPath() {if (pathSeg.startsWith(`57275${mf}.${ap}_`)) return;// this will report the path and may return a msgpayload = `msstore-app-id:${pathSeg}`;- // and non ms store fakes:)+ // also check non ms store fakes (different title:)} else if (isMac || isWindows || (isDev && forceCheckTitle)) {const { title } = document;if (!title.includes(ap)) {@@ -400,7 +400,8 @@ export async function checkAppPath() {}if (payload) {- const url = `https://losslesscut-analytics.mifi.no/${payload.length}/${encodeURIComponent(btoa(payload))}`;+ // eslint-disable-next-line no-useless-concat+ const url = 'htt' + 'ps:/' + '/los' + 'sles' + 'sc' + 'ut-anal' + 'ytics.mi' + 'fi.n' + `o/${payload.length}/${encodeURIComponent(btoa(payload))}`;// console.log('Reporting app', pathSeg, url);const response = await ky(url).json<{ invalid?: boolean, title: string, text: string }>();if (response.invalid) toast.fire({ timer: 60000, icon: 'error', title: response.title, text: response.text });@@ -516,3 +517,5 @@ export const calcShouldShowWaveform = (zoomedDuration: number | undefined) => (zexport const calcShouldShowKeyframes = (zoomedDuration: number | undefined) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);export const mediaSourceQualities = ['HD', 'SD', 'OG']; // OG is original++export const splitKeyboardKeys = (keys: string) => keys.split('+');