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

@@ -131,7 +131,12 @@ export class SelfbotStreamer implements ScreenStreamer {
// RTX 5050); otherwise it falls back to software x264.
const hw = this.config.streamHw;
const kbps = this.config.vncBitrateKbps;
const maxKbps = Math.round(kbps * 1.5);
// The library advertises a hardcoded max_bitrate of 10 Mbps to Discord
// (BaseMediaConnection: `max_bitrate: 10000 * 1000`). If the encoder bursts
// above that negotiated ceiling, WebRTC congestion control drops packets
// and the viewer sees stutter. Cap -maxrate at 10 Mbps to stay within it.
const LIB_MAX_BITRATE_KBPS = 10000;
const maxKbps = Math.min(Math.round(kbps * 1.5), LIB_MAX_BITRATE_KBPS);
const captureCodecArgs = hw
? ["-c:v", "h264_nvenc", "-preset", "p4", "-tune", "ll", "-forced-idr", "1"]
: ["-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency"];