Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: keep trim cursor monotonic for nested/overlapping trims
my_mac2a723f11c96d
diff --git a/src/lib/exporter/timelineSegments.test.ts b/src/lib/exporter/timelineSegments.test.tsindex be12062ee..cfd835032 100644--- a/src/lib/exporter/timelineSegments.test.ts+++ b/src/lib/exporter/timelineSegments.test.ts@@ -43,6 +43,22 @@ describe("computeKeepSegments", () => {{ startSec: 7, endSec: 10 },]);});++ it("does not re-emit source for a nested trim (cursor stays monotonic)", () => {+ // [4s,5s] is fully inside [2s,8s]; the inner trim must not drag the cursor back+ // to 5 and resurrect the already-trimmed [5s,8s] span.+ expect(computeKeepSegments(10, [trim(2000, 8000), trim(4000, 5000)])).toEqual([+ { startSec: 0, endSec: 2 },+ { startSec: 8, endSec: 10 },+ ]);+ });++ it("collapses overlapping trims into their union", () => {+ expect(computeKeepSegments(10, [trim(2000, 5000), trim(4000, 7000)])).toEqual([+ { startSec: 0, endSec: 2 },+ { startSec: 7, endSec: 10 },+ ]);+ });});describe("splitBySpeed", () => {diff --git a/src/lib/exporter/timelineSegments.ts b/src/lib/exporter/timelineSegments.tsindex e032de17b..c429651dc 100644--- a/src/lib/exporter/timelineSegments.ts+++ b/src/lib/exporter/timelineSegments.ts@@ -39,7 +39,10 @@ export function computeKeepSegments(if (cursor < trimStart) {segments.push({ startSec: cursor, endSec: trimStart });}- cursor = trimEnd;+ // Keep the cursor monotonic: a nested/overlapping trim (sorted only by start)+ // whose end is before the cursor must not move it backward and re-emit source+ // that an earlier trim already removed.+ cursor = Math.max(cursor, trimEnd);}if (cursor < totalDuration) {