Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: keep the capcodec bench pages off query-string URLs

Richie McIlroybd64face36a8
diff --git a/capcodec/README.md b/capcodec/README.md
index eab724a46..36500a5d9 100644
--- a/capcodec/README.md
+++ b/capcodec/README.md
@@ -1,6 +1,6 @@
# capcodec
-Tov source for the H.264 screen encoder used when `CAP_MEDIA_VIDEO_ENCODER=capcodec`. This directory is the `main` snapshot (`517b7e6`). Cap CI leaves it unbuilt. Mount a binary as described in `apps/media-server/capcodec.md`.
+Tov source for the H.264 screen encoder used when `CAP_MEDIA_VIDEO_ENCODER=capcodec`. This directory is the `main` snapshot (`517b7e6`). The full-motion page reads its media URL from `window.capVideoSrc`, which the corpus generator sets before load. Cap CI leaves it unbuilt. Mount a binary as described in `apps/media-server/capcodec.md`.
`capcodec.bundle` stores every branch. Restore it with `git clone capcodec.bundle`. The media-server flag runs `main`. `rd-next`, `ssim`, `intra-rd`, and `dashboard` stay on their own branches.
diff --git a/capcodec/bench/corpus/generate.py b/capcodec/bench/corpus/generate.py
index 1c72697d1..b3b22f3e6 100644
--- a/capcodec/bench/corpus/generate.py
+++ b/capcodec/bench/corpus/generate.py
@@ -32,8 +32,6 @@ import urllib.request
import zipfile
from dataclasses import dataclass, field
from pathlib import Path
-from urllib.parse import quote
-
import numpy as np
from Xlib import X
from Xlib import display as xdisplay
@@ -804,8 +802,6 @@ def capture(clip, xvfb):
pointer_file = work / "pointer.jsonl"
ff_cmd = ffmpeg_cmd(clip, clip.frames, work)
url = (PAGES / clip.page.split("?")[0]).as_uri() + (("?" + clip.page.split("?", 1)[1]) if "?" in clip.page else "")
- if video_meta:
- url += ("&" if "?" in url else "?") + "src=" + quote(Path(video_meta["file"]).as_uri(), safe="")
info = {"url": url, "calibration": calib}
if video_meta:
info["source_segment"] = video_meta
@@ -840,6 +836,10 @@ def capture(clip, xvfb):
console = []
page.on("console", lambda m: console.append(f"{m.type}: {m.text}") if m.type in ("error", "warning") else None)
page.on("pageerror", lambda e: console.append(f"pageerror: {e}"))
+ if video_meta:
+ page.add_init_script(
+ "window.capVideoSrc = " + json.dumps(Path(video_meta["file"]).as_uri()) + ";"
+ )
page.goto(url)
info["viewport"] = fit_window(clip, page)
page.wait_for_function("window.capReady === true", timeout=15000)
diff --git a/capcodec/bench/corpus/pages/common/video.js b/capcodec/bench/corpus/pages/common/video.js
index 21f15ac7c..508547c13 100644
--- a/capcodec/bench/corpus/pages/common/video.js
+++ b/capcodec/bench/corpus/pages/common/video.js
@@ -59,6 +59,7 @@
window.capTextRegions = () => [];
video.requestVideoFrameCallback(onFrame);
- video.src = params.get("src");
+ const src = window.capVideoSrc;
+ if (typeof src === "string") video.src = src;
video.play().catch((e) => cap.event("video_play_error", { message: String(e) }));
})();
diff --git a/capcodec/bench/corpus/pages/common/wiki.js b/capcodec/bench/corpus/pages/common/wiki.js
index f759b2004..ba1d668c7 100644
--- a/capcodec/bench/corpus/pages/common/wiki.js
+++ b/capcodec/bench/corpus/pages/common/wiki.js
@@ -307,8 +307,13 @@ ${[
clearTimeout(hoverTimer);
hoverTimer = setTimeout(() => {
const name = a.dataset.p || a.textContent;
+ const summary =
+ SUMMARIES[name] ||
+ `${name} is a topic related to the history of writing machines and office technology. It is covered in more detail in its own article.`;
const r = a.getBoundingClientRect();
- preview.innerHTML = `<div class="pb"><div class="pt">${name}</div>${SUMMARIES[name] || `${name} is a topic related to the history of writing machines and office technology. It is covered in more detail in its own article.`}</div><div class="pf"><span>⚙ Preferences</span><span>Read more ›</span></div>`;
+ preview.innerHTML = `<div class="pb"><div class="pt"></div></div><div class="pf"><span>⚙ Preferences</span><span>Read more ›</span></div>`;
+ preview.querySelector(".pt").textContent = name;
+ preview.querySelector(".pb").append(document.createTextNode(summary));
preview.style.left = `${Math.round(r.left + scrollX)}px`;
preview.style.top = `${Math.round(r.bottom + scrollY + 6)}px`;
preview.style.display = "block";