summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/mvxu3r_cam.html44
1 files changed, 31 insertions, 13 deletions
diff --git a/tools/mvxu3r_cam.html b/tools/mvxu3r_cam.html
index 928a912..42b1f5f 100644
--- a/tools/mvxu3r_cam.html
+++ b/tools/mvxu3r_cam.html
@@ -8,27 +8,44 @@
<script>
const v = document.getElementById('v'), i = document.getElementById('i');
let rv = 0, t0 = 0; // requestVideoFrameCallback counter
-let lastFrames = 0, lastT = 0, pq = 0; // getVideoPlaybackQuality counter
+let asked = 60; // the constraint below, for display
+/* Per-second history: an all-time average hides a burst at the start, and a
+ * third-party page reporting 15 fps cannot be reconciled with it otherwise. */
+let lastRv = 0, lastRvT = 0, hist = [];
function tick() { rv++; v.requestVideoFrameCallback(tick); }
function show() {
const s = v.srcObject;
if (!s) { i.textContent = 'no stream'; return; }
const t = s.getVideoTracks()[0], st = t.getSettings();
- const q = v.getVideoPlaybackQuality ? v.getVideoPlaybackQuality() : null;
const now = performance.now();
- if (q) {
- if (!lastT) { lastFrames = q.totalVideoFrames; lastT = now; }
- else if (now - lastT >= 1000) {
- pq = (q.totalVideoFrames - lastFrames) * 1000 / (now - lastT);
- lastFrames = q.totalVideoFrames; lastT = now;
- }
- }
const rvs = t0 ? rv / ((now - t0) / 1000) : 0;
- // getVideoPlaybackQuality().totalVideoFrames stays 0 in this build, so the
- // only honest number is requestVideoFrameCallback's rate.
+ if (!lastRvT) { lastRv = rv; lastRvT = now; }
+ else if (now - lastRvT >= 1000) {
+ hist.push((rv - lastRv) * 1000 / (now - lastRvT));
+ if (hist.length > 10) hist.shift();
+ lastRv = rv; lastRvT = now;
+ }
+ const h10 = hist.length;
+ const hmin = h10 ? Math.min(...hist) : 0, hmax = h10 ? Math.max(...hist) : 0;
+ const havg = h10 ? hist.reduce((a, b) => a + b, 0) / h10 : 0;
+ /*
+ * Three different numbers, and they are not interchangeable:
+ * asked = the constraint this page hands getUserMedia (ideal 60)
+ * settings = what Firefox says it negotiated. It reports 15 for this
+ * loopback whatever is asked, and it is NOT the delivery rate.
+ * measured = requestVideoFrameCallback's rate, the only honest number.
+ * getVideoPlaybackQuality().totalVideoFrames stays 0 in this build, so it is
+ * not used. The old label called settings.frameRate "requested", which made
+ * a 54 fps stream look like it was running at 15.
+ */
i.textContent = 'track: ' + (t.label || '(no label)') + ' ' + st.width + 'x' + st.height +
- ' requested ' + (st.frameRate ? st.frameRate.toFixed(0) : '?') + ' fps' +
- ' measured ' + rvs.toFixed(1) + ' fps state=' + t.readyState;
+ ' asked ' + asked + ' fps' +
+ ' settings ' + (st.frameRate ? st.frameRate.toFixed(0) : '?') + ' fps' +
+ ' measured ' + rvs.toFixed(1) + ' fps' +
+ ' last1s ' + (h10 ? hist[h10 - 1].toFixed(0) : '?') +
+ ' [min/avg/max over ' + h10 + 's ' + hmin.toFixed(0) + '/' +
+ havg.toFixed(1) + '/' + hmax.toFixed(0) + ']' +
+ ' state=' + t.readyState;
}
(async () => {
try {
@@ -36,6 +53,7 @@ function show() {
// reader that asks for a different geometry than the writer feeds gets a
// striped picture (measured 2026-10-24: 720p writer + 1080p request =
// interleaved lines). Asking for no geometry takes the device's own.
+ asked = 60;
const s = await navigator.mediaDevices.getUserMedia({video: {frameRate: {ideal: 60}}});
v.srcObject = s;
t0 = performance.now();