From 97d725537b7be3104815f9bece83911e6a7aedcd Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Wed, 3 Jun 2026 16:14:22 +0000 Subject: [PATCH] =?UTF-8?q?fix(capture):=20use=20ffmpeg=20rolling=20fps=20?= =?UTF-8?q?value=20for=20currentFps=20display=20=E2=80=94=20fixes=20wrong?= =?UTF-8?q?=20framerate=20shown=20on=20recorder=20tiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/capture/src/capture-manager.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/capture/src/capture-manager.js b/services/capture/src/capture-manager.js index ae76051..ee40d81 100644 --- a/services/capture/src/capture-manager.js +++ b/services/capture/src/capture-manager.js @@ -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);