Files
iptvnator/spikes/mpv-frame-copy/viewer/main.js
T
4grayandClaude Fable 5 10cf157f79 spike(embedded-mpv): frame-copy pipeline prototype (helper + shm ring + Electron viewer)
Standalone macOS spike for the frame-copy unification direction from the
2026-07-10 analysis: a helper process renders mpv offscreen into a GL FBO,
reads frames back through an async PBO ring, and publishes BGRA frames into
a 3-slot POSIX shm seqlock ring; a minimal Electron viewer copies the newest
frame via a plain-C N-API addon and uploads it to a WebGL canvas per rAF.

First numbers on M1 Pro (see spike README): 4K60 HEVC hwdec sustained at
60 fps end to end, ~1.2 ms shm copy + ~3.5 ms texture upload, ~10 ms
produce-to-upload age, zero torn frames. Remaining gates: weak hardware,
long-run pacing, HDR, latency flash test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 18:20:45 +02:00

31 lines
888 B
JavaScript

/*
* mpv frame-copy spike — Electron viewer harness.
*
* Deliberately minimal: nodeIntegration on, no preload, renderer console is
* mirrored to stdout so an automated run can scrape the STATS lines.
*/
const { app, BrowserWindow } = require('electron');
const path = require('path');
const shmName = process.env.SPIKE_SHM || '/mpv-frame-spike';
app.whenReady().then(() => {
const win = new BrowserWindow({
width: 1600,
height: 980,
backgroundColor: '#101014',
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
win.webContents.on('console-message', (_event, _level, message) => {
console.log(`[viewer] ${message}`);
});
win.loadFile(path.join(__dirname, 'index.html'), {
query: { shm: shmName },
});
});
app.on('window-all-closed', () => app.quit());