fix(selfbot): smooth VNC capture via keepalive + stop ffmpeg leak on stream end
The Go-Live broadcast looked badly choppy: video and scrolling stuttered while the cursor stayed smooth. Root cause is TigerVNC: it only refreshes its framebuffer while a VNC client is attached, but the broadcast reads that framebuffer with x11grab (not as a VNC client). With no viewer attached the captured screen idled at ~1.5 fps (measured 3/30 distinct frames); the cursor looked smooth only because x11grab overlays the live cursor on every frame. - Add a headless RFB keepalive (vnc-keepalive.ts) that stays connected for the life of the stream and requests incremental framebuffer updates at the stream framerate. SelfbotStreamer starts it on broadcast start and tears it down on stop/self-end. Measured 3/30 -> 57/60 distinct frames at 60 fps. Fail-open; authenticates with VNC_PASSWORD or the ~/.config/tigervnc/passwd file. - Fix a resource leak: when the Go-Live ended on its own, only the active flag was cleared, leaving the x11grab->nvenc ffmpeg running forever (pinning a CPU core while no media was transmitted, with only the gateway TCP left and no UDP media). The self-end path now tears down capture, keepalive and voice like stop() does. - Tests for both paths (self-end teardown; keepalive DES auth, port mapping, password resolution). Add @types/bun so bun:test typechecks; document the keepalive and recommended Chrome flags in README and .env.example. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,25 @@ bun bot/scripts/stream-test/stream-hold.ts
|
||||
node bot/scripts/stream-test/scenario.mjs
|
||||
```
|
||||
|
||||
Recommended Chrome flags on the streamed display (avoids the "restore pages?"
|
||||
bubble after an unclean exit and keeps a single clean window):
|
||||
```
|
||||
google-chrome --remote-debugging-port=9222 --start-maximized \
|
||||
--hide-crash-restore-bubble --disable-session-crashed-bubble \
|
||||
--autoplay-policy=no-user-gesture-required <url>
|
||||
```
|
||||
|
||||
## Smooth capture (VNC keepalive)
|
||||
TigerVNC only refreshes its framebuffer while a VNC client is attached. The
|
||||
Discord broadcast reads the framebuffer with `x11grab` (not as a VNC client), so
|
||||
with no viewer attached the captured screen idles at ~1.5 fps and the stream
|
||||
looks badly choppy while the cursor still moves smoothly (x11grab overlays the
|
||||
live cursor each frame). `SelfbotStreamer` fixes this automatically: it keeps a
|
||||
tiny headless RFB client (`vnc-keepalive.ts`) connected for the life of the
|
||||
stream, requesting incremental updates at the stream framerate. Measured: 3/30
|
||||
distinct frames without it, ~57/60 with it. The keepalive authenticates with
|
||||
`VNC_PASSWORD` (or the `~/.config/tigervnc/passwd` file) and is fail-open.
|
||||
|
||||
## A/B framerate/resolution
|
||||
Lower settings to compare what Discord actually delivers to viewers, e.g.:
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user