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);