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(export): keep speed segments non-overlapping
Arham Wania732ab493293
diff --git a/src/lib/exporter/timelineSegments.test.ts b/src/lib/exporter/timelineSegments.test.tsindex cfd835032..2eeb910c1 100644--- a/src/lib/exporter/timelineSegments.test.ts+++ b/src/lib/exporter/timelineSegments.test.ts@@ -100,6 +100,23 @@ describe("splitBySpeed", () => {]);});+ it("keeps output disjoint when speed regions overlap", () => {+ expect(splitBySpeed(full, [speed(1000, 5000, 2), speed(4000, 7000, 3)])).toEqual([+ { startSec: 0, endSec: 1, speed: 1 },+ { startSec: 1, endSec: 5, speed: 2 },+ { startSec: 5, endSec: 7, speed: 3 },+ { startSec: 7, endSec: 10, speed: 1 },+ ]);+ });++ it("ignores a later speed region fully covered by the earliest region", () => {+ expect(splitBySpeed(full, [speed(1000, 8000, 2), speed(3000, 5000, 3)])).toEqual([+ { startSec: 0, endSec: 1, speed: 1 },+ { startSec: 1, endSec: 8, speed: 2 },+ { startSec: 8, endSec: 10, speed: 1 },+ ]);+ });+it("drops sub-segments narrower than the minimum width", () => {// A speed region ending a sliver before the segment end must not emit a 1x crumb.const result = splitBySpeed(full, [speed(0, 9_999.95, 2)]);diff --git a/src/lib/exporter/timelineSegments.ts b/src/lib/exporter/timelineSegments.tsindex c429651dc..9c2c3c2d4 100644--- a/src/lib/exporter/timelineSegments.ts+++ b/src/lib/exporter/timelineSegments.ts@@ -80,8 +80,11 @@ export function splitBySpeed(for (const sr of overlapping) {const srStart = Math.max(sr.startMs / 1000, segment.startSec);const srEnd = Math.min(sr.endMs / 1000, segment.endSec);- if (cursor < srStart) result.push({ startSec: cursor, endSec: srStart, speed: 1 });- result.push({ startSec: srStart, endSec: srEnd, speed: sr.speed });+ if (srEnd <= cursor) continue;+ const effectiveStart = Math.max(srStart, cursor);+ if (cursor < effectiveStart)+ result.push({ startSec: cursor, endSec: effectiveStart, speed: 1 });+ result.push({ startSec: effectiveStart, endSec: srEnd, speed: sr.speed });cursor = srEnd;}if (cursor < segment.endSec)