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:
47
bot/scripts/stream-test/stream-hold.ts
Normal file
47
bot/scripts/stream-test/stream-hold.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
// Persistent selfbot stream holder for manual/operational testing of the
|
||||
// Go-Live broadcast. Joins the voice channel, goes live, and keeps the stream
|
||||
// up until stopped (SIGTERM/SIGINT) or HOLD_MS elapses. All parameters come
|
||||
// from the environment (.env).
|
||||
//
|
||||
// bun bot/scripts/stream-test/stream-hold.ts
|
||||
//
|
||||
// Requires in .env: DISCORD_SELFBOT_TOKEN, DISCORD_GUILD_ID,
|
||||
// DISCORD_VOICE_CHANNEL_ID. Stream params: VNC_RESOLUTION, VNC_FRAMERATE,
|
||||
// VNC_BITRATE_KBPS, STREAM_HW, VNC_DISPLAY (same vars the bot uses).
|
||||
import "dotenv/config";
|
||||
import { SelfbotStreamer } from "../../src/stream/selfbot.ts";
|
||||
|
||||
const config = {
|
||||
selfbotToken: process.env.DISCORD_SELFBOT_TOKEN ?? "",
|
||||
vncDisplay: process.env.VNC_DISPLAY ?? ":1",
|
||||
vncResolution: process.env.VNC_RESOLUTION ?? "1920x1080",
|
||||
vncFramerate: parseInt(process.env.VNC_FRAMERATE ?? "60", 10),
|
||||
vncBitrateKbps: parseInt(process.env.VNC_BITRATE_KBPS ?? "8000", 10),
|
||||
streamHw: (process.env.STREAM_HW ?? "1") !== "0",
|
||||
} as any;
|
||||
|
||||
const guildId = process.env.DISCORD_GUILD_ID;
|
||||
const voiceChannelId = process.env.DISCORD_VOICE_CHANNEL_ID;
|
||||
if (!config.selfbotToken || !guildId || !voiceChannelId) {
|
||||
console.error("Missing DISCORD_SELFBOT_TOKEN / DISCORD_GUILD_ID / DISCORD_VOICE_CHANNEL_ID in .env");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const s = new SelfbotStreamer(config);
|
||||
const maxMs = parseInt(process.env.HOLD_MS ?? "7200000", 10);
|
||||
let stopped = false;
|
||||
const stop = async () => {
|
||||
if (stopped) return;
|
||||
stopped = true;
|
||||
console.log("STREAM_STOPPING");
|
||||
await s.stop();
|
||||
console.log("STREAM_STOPPED");
|
||||
process.exit(0);
|
||||
};
|
||||
process.on("SIGTERM", stop);
|
||||
process.on("SIGINT", stop);
|
||||
|
||||
const r = await s.start({ guildId, voiceChannelId } as any);
|
||||
console.log(`STREAM_START: ${r} active:${s.isActive()} (${config.vncResolution}@${config.vncFramerate} ${config.vncBitrateKbps}k hw=${config.streamHw})`);
|
||||
setTimeout(stop, maxMs);
|
||||
setInterval(() => {}, 60000);
|
||||
Reference in New Issue
Block a user