fix(producer): every video's size samples share one grid (#7782)

* fix(producer): every video's size samples share one grid

Videos with offset starts each added a full set of seek times; on one shared grid the count follows the composition's length, not the number of video tags.

* fix(producer): keep the shown-box times comment to one line
This commit is contained in:
Miguel Ángel
2026-11-14 19:57:41 -05:00
committed by GitHub
parent f99995abb2
commit 1d83e2520a
2 changed files with 13 additions and 3 deletions
@@ -70,6 +70,11 @@ describe("shownBoxTimes", () => {
expect(shownBoxTimes([video("a", 2 ** 53, 2 ** 54)], fps, 10)).toEqual([]);
expect(shownBoxTimes([video("a", Number.NaN, 1)], fps, 10)).toEqual([]);
});
it("puts every video's strides on one grid, so many offset videos add only their own first and last frames", () => {
const offset = Array.from({ length: 1000 }, (_, i) => video(`v${i}`, i / 1000, 10));
expect(shownBoxTimes(offset, fps, 10).length).toBeLessThanOrEqual(10 / 0.25 + 2 * 1000);
});
});
describe("measureLocalShownBoxes", () => {
@@ -35,7 +35,7 @@ export async function oversizedVideos(
return videos.filter((_, index) => sized[index]);
}
/** Each video's first and last frame before `duration` and every stride between, in seconds, ascending. */
/** Each video's first and last frame before `duration`, and the one stride grid all videos share between. */
export function shownBoxTimes(
videos: readonly VideoElement[],
fps: { num: number; den: number },
@@ -47,8 +47,13 @@ export function shownBoxTimes(
const end = Math.min(authoredEnd, duration);
if (!Number.isFinite(start) || !Number.isFinite(end) || start > end) continue;
const last = Math.max(start, end - frame);
for (let step = 0; start + step * SHOWN_BOX_STRIDE_S < last; step += 1) {
times.add(start + step * SHOWN_BOX_STRIDE_S);
times.add(start);
for (
let step = Math.floor(start / SHOWN_BOX_STRIDE_S) + 1;
step * SHOWN_BOX_STRIDE_S < last;
step += 1
) {
times.add(step * SHOWN_BOX_STRIDE_S);
}
times.add(last);
}