diff --git a/src/App.jsx b/src/App.jsx index eb6d0c7ccc8..a1504ddfd9a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -996,7 +996,8 @@ const App = memo(() => { setExportConfirmVisible(false); - const filteredOutSegments = exportSingle ? [outSegments[currentSegIndexSafe]] : outSegments; + const outSegmentsWithOrder = outSegments.map((s, order) => ({ ...s, order })); + const filteredOutSegments = exportSingle ? [outSegmentsWithOrder[currentSegIndexSafe]] : outSegmentsWithOrder; try { setWorking(i18n.t('Exporting')); @@ -1011,6 +1012,7 @@ const App = memo(() => { rotation: isRotationSet ? effectiveRotation : undefined, copyFileStreams, keyframeCut, + invertCutSegments, segments: filteredOutSegments, onProgress: setCutProgress, appendFfmpegCommandLog, @@ -1576,7 +1578,7 @@ const App = memo(() => { if (hasVideo) { if (isDurationValid(await getDuration(filePath))) { showToast(); - await tryCreateDummyVideo(); + await tryCreateDummyVideo(); } } else if (hasAudio) { showToast(); diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 357d63ad3d4..0df339d597f 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -308,7 +308,7 @@ export async function cutMultiple({ customOutDir, filePath, segments, videoDuration, rotation, onProgress, keyframeCut, copyFileStreams, outFormat, isCustomFormatSelected, appendFfmpegCommandLog, shortestFlag, ffmpegExperimental, preserveMovData, avoidNegativeTs, - customTagsByFile, customTagsByStreamId, + customTagsByFile, customTagsByStreamId, invertCutSegments, }) { console.log('customTagsByFile', customTagsByFile); console.log('customTagsByStreamId', customTagsByStreamId); @@ -323,10 +323,14 @@ export async function cutMultiple({ let i = 0; // eslint-disable-next-line no-restricted-syntax,no-unused-vars - for (const { start, end, name } of segments) { + for (const { start, end, name, order } of segments) { const cutFromStr = formatDuration({ seconds: start, fileNameFriendly: true }); const cutToStr = formatDuration({ seconds: end, fileNameFriendly: true }); - const segNamePart = name ? `-${filenamify(name)}` : ''; + let segNamePart = ''; + if (!invertCutSegments) { + if (name) segNamePart = `-${filenamify(name)}`; + else segNamePart = `-seg${order + 1}`; + } const cutSpecification = `${cutFromStr}-${cutToStr}${segNamePart}`.substr(0, 200); const ext = getOutFileExtension({ isCustomFormatSelected, outFormat, filePath }); const fileName = `${cutSpecification}${ext}`;