fix: cap selfbot stream -maxrate at lib's 10 Mbps ceiling; add stream-test tooling

- selfbot.ts: the @dank074 lib advertises a hardcoded max_bitrate of 10 Mbps to
  Discord (BaseMediaConnection: `max_bitrate: 10000 * 1000`). Our encoder used
  -maxrate = 1.5x target (12 Mbps at 8 Mbps target), so high-motion bursts
  exceeded the negotiated ceiling and WebRTC dropped packets (viewer stutter).
  Cap -maxrate at 10 Mbps.
- Add bot/scripts/stream-test/: env-driven stream-hold.ts (persistent Go-Live
  holder), human.mjs (real xdotool mouse/keyboard + char-by-char typing), and
  scenario.mjs (YouTube/Naver browse). Channel/guild/video are env-parametrised.
- .env.example: document DISCORD_VOICE_CHANNEL_ID for the stream-test scripts.
This commit is contained in:
javis-bot
2026-06-10 12:50:24 +09:00
parent 7a148f8caa
commit 1e30a49562
6 changed files with 274 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
# stream-test
Operational scripts for manually verifying the selfbot Go-Live broadcast with a
real browsing session captured from the X display.
## Files
- `stream-hold.ts` - joins the voice channel and keeps the Go-Live stream up
until stopped. All params from `.env` (`DISCORD_SELFBOT_TOKEN`,
`DISCORD_GUILD_ID`, `DISCORD_VOICE_CHANNEL_ID`, `VNC_RESOLUTION`,
`VNC_FRAMERATE`, `VNC_BITRATE_KBPS`, `STREAM_HW`, `VNC_DISPLAY`).
- `human.mjs` - human-like interaction helpers. Real mouse/keyboard via
`xdotool` (so the cursor is visible in the stream); Playwright locates
elements. Behind-the-scenes control (fullscreen, play, quality, autoplay,
navigation) uses the CDP/DOM API.
- `scenario.mjs` - the browse scenario (YouTube -> IU live -> 1080p ->
fullscreen -> Naver -> 나무위키), driven with the human helpers. Connects to a
Chrome already running with `--remote-debugging-port` (`CDP_PORT`, default
9222) on the streamed display.
## Run
```
# keep the broadcast up (separate process / service)
bun bot/scripts/stream-test/stream-hold.ts
# Chrome on the streamed display with remote debugging, then:
node bot/scripts/stream-test/scenario.mjs
```
## A/B framerate/resolution
Lower settings to compare what Discord actually delivers to viewers, e.g.:
```
VNC_RESOLUTION=1280x720 VNC_FRAMERATE=30 bun bot/scripts/stream-test/stream-hold.ts
```
## Notes
- Selfbot streaming violates Discord ToS; use a burner account.
- Requires `xdotool`, an X display, and a system `ffmpeg` with `x11grab`/nvenc.
- Prereqs (`playwright`, system Chrome) are not bot dependencies; install
separately where you run the scenario.