Skip to content

Commit

Permalink
Include segment number in output file
Browse files Browse the repository at this point in the history
for segment without any label
Fixed #536
  • Loading branch information
mifi committed Dec 11, 2020
1 parent 3cedc45 commit c7b04e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -1011,6 +1012,7 @@ const App = memo(() => {
rotation: isRotationSet ? effectiveRotation : undefined,
copyFileStreams,
keyframeCut,
invertCutSegments,
segments: filteredOutSegments,
onProgress: setCutProgress,
appendFfmpegCommandLog,
Expand Down Expand Up @@ -1576,7 +1578,7 @@ const App = memo(() => {
if (hasVideo) {
if (isDurationValid(await getDuration(filePath))) {
showToast();
await tryCreateDummyVideo();
await tryCreateDummyVideo();
}
} else if (hasAudio) {
showToast();
Expand Down
10 changes: 7 additions & 3 deletions src/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}`;
Expand Down

0 comments on commit c7b04e9

Please sign in to comment.