fix(capture): use ffmpeg rolling fps value for currentFps display — fixes wrong framerate shown on recorder tiles

This commit is contained in:
Zac Gaetano 2026-06-03 16:14:22 +00:00
parent d654f7c8a1
commit 97d725537b

View file

@ -1091,12 +1091,13 @@ exit "$BMXRC"
if (m) {
this.state.framesReceived = parseInt(m[1], 10);
this.state.lastFrameAt = new Date().toISOString();
if (this.state.recordingStartedAt) {
const elapsedSec = (Date.now() - this.state.recordingStartedAt) / 1000;
if (elapsedSec > 0) {
this.state.currentFps = Math.round((this.state.framesReceived / elapsedSec) * 100) / 100;
}
}
// Use ffmpeg's own rolling fps value — it is a short-window average
// computed by ffmpeg itself and correctly reflects the true encode rate.
// The previous frame/elapsed cumulative calculation dragged low during
// startup and was permanently wrong for growing-path (bash orchestrator
// stderr doesn't emit frame= lines until ffmpeg flushes them).
const ffmpegFps = parseFloat(m[2]);
if (ffmpegFps > 0) this.state.currentFps = Math.round(ffmpegFps * 100) / 100;
}
if (/Connection refused|No route to host|Connection failed|Input\/output error|Server returned|404 Not Found|Connection timed out/i.test(text)) {
this.state.lastError = text.trim().slice(0, 240);