Spaces:
Runtime error
Runtime error
Commit History
-
perf(stream): drift-free pacer + reader pacing for true 25 fps smoothness
Three fixes layered to eliminate the "smooth → freeze → burst" cycle caused by upstream HLS segment-burst delivery: 1. Drift-free pacer scheduler The pacer now anchors every tick at an absolute monotonic target (start + N*period) with a ~2 ms busy-wait tail. time.sleep() on macOS overshoots by ~3-5 ms because the kernel timer tick is coarse, which was silently drifting the pacer to ~22.7 fps even when work was only 4 ms. Effective pacer rate is now 25.0 fps measured. 2. Reader pacing at HLS_FPS stream_reader.cap.read() was draining ffmpeg's HLS demuxer as fast as it could decode, dumping a full ~50-frame segment into the ring in ~100 ms. The ring's drop-oldest semantics then threw away ~47 % of every burst, producing temporal discontinuities visible downstream as fast-forward bursts followed by frozen frames. Pacing cap.read() at HLS_FPS lets TCP / ffmpeg backpressure smooth the source delivery; the ring now stays at length 1-2 and source fra…abc7cb8