Stop serving a stale video frame as if the stream were live - #107
Merged
Conversation
This was referenced Jul 29, 2026
leandropineda
changed the base branch from
perf/video-decode-throttle
to
perf/decode-at-publish-rate
July 29, 2026 22:39
leandropineda
force-pushed
the
fix/video-frame-staleness
branch
from
July 29, 2026 22:41
150407f to
a489c23
Compare
get_frame_jpg() re-encoded the last decoded frame for as long as the stream stayed down, so the platform kept showing a frozen image that looked live -- the worst failure mode for a safety camera, and one that hides the outage from whoever is watching. Frames older than the new stale_frame_seconds (default 3s, ~3x the age a frame reaches at the default publish rate) are not served, so the platform shows no video instead. Pass stale_frame_seconds=None for the previous behaviour. Tests: 1 new case in test_video.py.
A fixed 3s window is wrong for a slow rate: at one frame every 10s a
3s-old frame is perfectly normal, so every frame would be withheld and
video would stop entirely.
The window now defaults to three publish periods -- 1s at 10 fps, 3s at 1
fps (unchanged from before), 30s at 0.1 fps -- with a 1s floor so a fast
rate does not withhold frames on ordinary jitter. An explicit
stale_frame_seconds still wins, and float("inf") disables the check.
Tests: 1 new case, 1 updated in test_video.py.
leandropineda
force-pushed
the
fix/video-frame-staleness
branch
from
July 29, 2026 22:51
a489c23 to
ec99000
Compare
A stale frame is dropped silently, so an operator sees the video stop with nothing saying why. Debug level because this is reached on every publish for as long as the stream stays down; the per-minute capture health line carries the count for normal operation.
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.
Stacked on #106.
get_frame_jpg()re-encoded the last decoded frame for as long as the stream stayed down, so the platform kept showing a frozen image that looked live — the worst failure mode for a safety camera, and it hides the outage from whoever is watching.Frames older than the new
stale_frame_seconds(default 3s, ~3× the age a frame reaches at the default publish rate) are no longer served, so the platform shows no video instead.stale_frame_seconds=Nonerestores the old behaviour.Behaviour change worth calling out in release notes.
Tests: 1 new case. Suite green, flake8/black clean.