Skip to content

The swiss army knife of lossless video/audio editing

don't create detected segments twice

Mikael Finstad0114faf2d12c
diff --git a/src/main/ffmpeg.ts b/src/main/ffmpeg.ts
index 8713b9ce..be2b5e6f 100644
--- a/src/main/ffmpeg.ts
+++ b/src/main/ffmpeg.ts
@@ -317,11 +317,15 @@ async function detectIntervals({ filePath, customArgs, onProgress, from, to, mat
start: midpoints[i - 1] ?? 0,
end: time,
},
- {
- start: time,
- end: midpoints[i + 1] ?? (to - from),
- },
]);
+
+ const lastMidpoint = midpoints.at(-1);
+ if (lastMidpoint != null) {
+ segments.push({
+ start: lastMidpoint,
+ end: to - from,
+ });
+ }
}
return adjustSegmentsWithOffset({ segments, from });