Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

docs(export): state the overlap rule splitBySpeed now enforces

Etienne Lescot29ad2de17a15
diff --git a/src/lib/exporter/timelineSegments.test.ts b/src/lib/exporter/timelineSegments.test.ts
index 2eeb910c1..5ac0e3b0c 100644
--- a/src/lib/exporter/timelineSegments.test.ts
+++ b/src/lib/exporter/timelineSegments.test.ts
@@ -109,6 +109,12 @@ describe("splitBySpeed", () => {
]);
});
+ // Not a variant of the test above: there the two regions merely overlap, here the
+ // second is fully swallowed by the first. main emitted
+ // `[0-1 x1, 1-8 x2, 3-5 x3, 5-10 x1]` — the third entry starts BEFORE the second
+ // ends, so the list stops being ascending and 5-8 ships twice. `decodeAll` walks
+ // these with a forward-only frame cursor, so that is a backwards seek, not just a
+ // duplicated stretch. Keep both cases.
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 },
diff --git a/src/lib/exporter/timelineSegments.ts b/src/lib/exporter/timelineSegments.ts
index 9c2c3c2d4..d366c4da6 100644
--- a/src/lib/exporter/timelineSegments.ts
+++ b/src/lib/exporter/timelineSegments.ts
@@ -54,8 +54,14 @@ export function computeKeepSegments(
/**
* Splits keep-segments by overlapping speed regions, annotating each sub-segment
- * with its playback speed multiplier (defaults to 1×). Regions are assumed
- * non-overlapping; when they do overlap the earliest-starting one wins.
+ * with its playback speed multiplier (defaults to 1×).
+ *
+ * Overlapping regions are handled rather than assumed away: the earliest-starting
+ * one keeps the stretch it already covers, and a later region contributes only the
+ * part past the cursor (nothing at all when it is fully covered). Output is always
+ * disjoint and ascending — `decodeAll` walks it with a forward-only frame cursor,
+ * so an overlap would otherwise duplicate source and seek backwards. Same rule as
+ * the native path's `speed_segments_for_window` in `crates/compositor/src/regions.rs`.
*/
export function splitBySpeed(
segments: TimelineSegment[],