The swiss army knife of lossless video/audio editing
add key binding for fix invalid duration
Mikael Finstad354fce616c8d
diff --git a/src/App.jsx b/src/App.jsxindex 270d1573..258791af 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -1707,6 +1707,21 @@ const App = memo(() => {const toggleKeyboardShortcuts = useCallback(() => setKeyboardShortcutsVisible((v) => !v), []);+ const tryFixInvalidDuration = useCallback(async () => {+ if (!checkFileOpened() || workingRef.current) return;+ try {+ setWorking(i18n.t('Fixing file duration'));+ const path = await fixInvalidDuration({ fileFormat, customOutDir });+ toast.fire({ icon: 'info', text: i18n.t('Duration has been fixed') });+ await loadMedia({ filePath: path, customOutDir });+ } catch (err) {+ errorToast(i18n.t('Failed to fix file duration'));+ console.error('Failed to fix file duration', err);+ } finally {+ setWorking();+ }+ }, [checkFileOpened, customOutDir, fileFormat, fixInvalidDuration, loadMedia, setWorking]);+const onKeyPress = useCallback(({ action, keyup }) => {function seekReset() {seekAccelerationRef.current = 1;@@ -1792,6 +1807,7 @@ const App = memo(() => {enableAllSegments,enableOnlyCurrentSegment,toggleCurrentSegmentEnabled,+ fixInvalidDuration: tryFixInvalidDuration,};function tryMainActions() {@@ -1833,7 +1849,7 @@ const App = memo(() => {if (match) return bubble;return true; // bubble the event- }, [addCutSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, currentSegIndexSafe, cutSegmentsHistory, disableAllSegments, enableAllSegments, enableOnlyCurrentSegment, exportConfirmVisible, extractAllStreams, goToTimecode, increaseRotation, invertAllCutSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegmentPress, pause, play, removeCutSegment, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, setCutEnd, setCutStart, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentEnabled, toggleHelp, toggleKeyboardShortcuts, toggleKeyframeCut, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, userHtml5ifyCurrentFile, zoomRel]);+ }, [addCutSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, currentSegIndexSafe, cutSegmentsHistory, disableAllSegments, enableAllSegments, enableOnlyCurrentSegment, exportConfirmVisible, extractAllStreams, goToTimecode, increaseRotation, invertAllCutSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegmentPress, pause, play, removeCutSegment, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, setCutEnd, setCutStart, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentEnabled, toggleHelp, toggleKeyboardShortcuts, toggleKeyframeCut, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, tryFixInvalidDuration, userHtml5ifyCurrentFile, zoomRel]);useKeyboard({ keyBindings, onKeyPress });@@ -2035,21 +2051,6 @@ const App = memo(() => {}}- async function fixInvalidDuration2() {- if (!checkFileOpened() || workingRef.current) return;- try {- setWorking(i18n.t('Fixing file duration'));- const path = await fixInvalidDuration({ fileFormat, customOutDir });- toast.fire({ icon: 'info', text: i18n.t('Duration has been fixed') });- await loadMedia({ filePath: path, customOutDir });- } catch (err) {- errorToast(i18n.t('Failed to fix file duration'));- console.error('Failed to fix file duration', err);- } finally {- setWorking();- }- }-const action = {openFiles: (event, filePaths) => { userOpenFiles(filePaths.map(resolvePathIfNeeded)); },closeCurrentFile: () => { closeFileWithConfirm(); },@@ -2070,7 +2071,7 @@ const App = memo(() => {createNumSegments,createFixedDurationSegments,invertAllCutSegments,- fixInvalidDuration: fixInvalidDuration2,+ fixInvalidDuration: tryFixInvalidDuration,reorderSegsByStartTime,concatCurrentBatch,};@@ -2078,7 +2079,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, customOutDir, cutSegments, extractAllStreams, fileFormat, filePath, fixInvalidDuration, getFrameCount, getTimeFromFrameNum, invertAllCutSegments, loadCutSegments, loadMedia, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shuffleSegments, toggleHelp, toggleSettings, userHtml5ifyCurrentFile, userOpenFiles]);+ }, [apparentCutSegments, askSetStartTimeOffset, checkFileOpened, clearSegments, closeBatch, closeFileWithConfirm, concatCurrentBatch, createFixedDurationSegments, createNumSegments, customOutDir, cutSegments, extractAllStreams, fileFormat, filePath, getFrameCount, getTimeFromFrameNum, invertAllCutSegments, loadCutSegments, loadMedia, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shuffleSegments, toggleHelp, toggleSettings, tryFixInvalidDuration, userHtml5ifyCurrentFile, userOpenFiles]);const showAddStreamSourceDialog = useCallback(async () => {try {diff --git a/src/components/KeyboardShortcuts.jsx b/src/components/KeyboardShortcuts.jsxindex 575275c3..acbbb935 100644--- a/src/components/KeyboardShortcuts.jsx+++ b/src/components/KeyboardShortcuts.jsx@@ -347,12 +347,16 @@ const KeyboardShortcuts = memo(({name: t('Delete source file'),category: outputCategory,},+ convertFormatBatch: {+ name: t('Batch convert files to supported format'),+ category: outputCategory,+ },convertFormatCurrentFile: {name: t('Convert current file to supported format'),category: outputCategory,},- convertFormatBatch: {- name: t('Batch convert files to supported format'),+ fixInvalidDuration: {+ name: t('Fix incorrect duration'),category: outputCategory,},diff --git a/src/mifi.js b/src/mifi.jsindex 4dc8c476..7a0c8d46 100644--- a/src/mifi.js+++ b/src/mifi.js@@ -5,7 +5,7 @@ export async function loadMifiLink() {try {// In old versions: https://mifi.no/losslesscut/config.jsonconst resp = await axios.get('https://losslesscut.mifi.no/config.json');- // const resp = await axios.get('http://localhost:8080/config-dev.json');+ // const resp = await axios.get('http://localhost:8080/losslesscut/config-dev.json');return resp.data;} catch (err) {return undefined;