feat(realtime): cap capture FPS at 30 via ideal/max constraint#141
Merged
Conversation
…-model rate Realtime models now request capture FPS via a constraint object so the camera delivers its native rate (typically 24/25/30) and the server resamples to the model's required rate. This decouples the SDK from server-side FPS support and ensures a steady frame supply to inference. User-facing pattern is unchanged: `frameRate: model.fps` still compiles because MediaTrackConstraints["frameRate"] accepts both number and constraint-object forms. Video/image model `fps` stays numeric (output-rate metadata).
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Realtime models now request capture FPS via an
{ ideal: 30, max: 30 }constraint instead of a hardcoded per-model rate (was 20 for Lucy 2.1, 22 for Lucy Restyle 2). The camera delivers its native rate (typically 24/25/30) and the server resamples to whatever the model needs.Why
User-facing impact
None for the documented pattern —
frameRate: model.fpsingetUserMediastill compiles and works, becauseMediaTrackConstraints["frameRate"]natively accepts bothnumberand constraint-object forms:Video/image model
fpsstays anumber(it's output-rate metadata, not a capture constraint); the type narrowing is enforced at themodels.video(...)/models.image(...)getter boundary so consumers of those registries see no change.Test plan
pnpm typecheckpassespnpm test— 199/199 unit tests pass (added regression guard that video/imagefpsstays typed asnumber)pnpm test:e2e:realtimeagainst staging across all realtime modelstrack.getSettings().frameRateis ≤ 30 across cameras with native 24/25/30/60 ratesNote
Medium Risk
Changes the public
models.realtime(...).fpsshape from a number to a constraint object, which may break consumers doing numeric operations or passing it to APIs expecting a scalar. Runtime behavior changes capture/mirroring FPS handling, so regressions would show up as altered stream cadence or compatibility issues in edge browsers.Overview
Realtime model FPS is now represented as a capture constraint object rather than a fixed per-model number. The realtime registry entries switch to
fps: { ideal: 30, max: 30 }, andmodelDefinitionSchema/ModelDefinitionare updated to accept either a number or constraint-object form.Adds
resolveFpsNumber()to derive a scalar FPS when needed, and uses it inrealtime/client.tswhen creating mirrored streams. Tests are updated to assert the new realtimefpsshape, add coverage forresolveFpsNumber, and ensuremodels.video(...)/models.image(...)still exposefpsas anumber; the realtime E2E synthetic stream now captures at 30 FPS explicitly.Reviewed by Cursor Bugbot for commit 49342d1. Bugbot is set up for automated code reviews on this repo. Configure here.