Skip to content

Add optional pacing for bursty Xiaomi CS2 video - #2411

Draft
RuiFG wants to merge 2 commits into
AlexxIT:masterfrom
RuiFG:agent/fix-xiaomi-cs2-video-pacing
Draft

Add optional pacing for bursty Xiaomi CS2 video#2411
RuiFG wants to merge 2 commits into
AlexxIT:masterfrom
RuiFG:agent/fix-xiaomi-cs2-video-pacing

Conversation

@RuiFG

@RuiFG RuiFG commented Aug 8, 2026

Copy link
Copy Markdown

What changed

  • add an optional pacing parameter to Xiaomi MISS/CS2 sources
  • buffer complete video access units and release them on the media timestamp timeline
  • bound catch-up behavior when the queue grows
  • keep the pacing clock on its scheduled timeline so timer wake-up overshoot cannot accumulate into seconds of latency
  • document the option and add pacing/backlog/drift tests

Why

Some Xiaomi CS2 cameras deliver video in bursts. Downstream consumers such as HomeKit may render those bursts as periodic stalls. Pacing the access units smooths delivery, but anchoring each frame to the timer's actual wake-up time caused normal scheduler overshoot to accumulate during long-running prebuffer sessions. In testing, restarting go2rtc immediately reset roughly ten seconds of built-up delay to about two seconds.

The pacing option remains disabled unless a source explicitly sets it, for example pacing=120.

Validation

  • go test ./pkg/xiaomi/miss ./pkg/xiaomi/miss/cs2
  • simulated 10-minute, 20 fps pacing run with 1 ms timer overshoot per frame; no accumulated drift
  • Xiaomi xiaomi.camera.083ac1 test stream through go2rtc, Scrypted, and HomeKit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant