feat(selfbot): broadcast desktop audio + smart subtitles in the browse scenario

Two broadcast-experience improvements:

- Audio: the Go-Live stream was video-only. Capture the desktop sound (the
  default PipeWire/Pulse sink monitor, @DEFAULT_MONITOR@) as a second ffmpeg
  input and mux AAC into the mpegts; the library re-encodes it to Opus for
  Discord. Controlled by STREAM_AUDIO / STREAM_AUDIO_SOURCE (default on). ffmpeg
  inherits XDG_RUNTIME_DIR to reach the pulse socket. Verified: the streamer now
  reports "Found audio stream" and the monitor carries Chrome audio (~-11 dB).
- Subtitles: in the browse scenario, default captions OFF, but auto-enable a
  Korean track when the video offers one (getOption captions tracklist ->
  setOption / unloadModule).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-06-10 15:50:32 +09:00
parent c6a0ca4572
commit 208fbbc851
5 changed files with 44 additions and 0 deletions

View File

@@ -43,6 +43,23 @@ async function browserFullscreen(on) {
} catch { /* best-effort */ }
}
// Subtitles: OFF by default, but turn ON Korean when a Korean track exists.
async function applyCaptions() {
await read(() => { try { document.getElementById('movie_player')?.loadModule?.('captions'); } catch {} });
await sleep(800);
return read(() => {
const pl = document.getElementById('movie_player');
if (!pl || !pl.getOption) return 'no-player';
let tracks = [];
try { tracks = pl.getOption('captions', 'tracklist') || []; } catch {}
const ko = tracks.find((t) => /^ko/i.test(t.languageCode || ''));
if (ko) { try { pl.setOption('captions', 'track', { languageCode: ko.languageCode }); } catch {} return 'ko-on'; }
try { pl.setOption('captions', 'track', {}); } catch {}
try { pl.unloadModule('captions'); } catch {}
return 'off';
});
}
// 1) open YouTube by typing the URL in the address bar
await navigateOmnibox('https://www.youtube.com'); await sleep(3000);
@@ -84,6 +101,7 @@ async function setQuality1080() {
return null;
}
console.log('QUALITY', await setQuality1080());
console.log('CAPTIONS', await applyCaptions());
// 6) turn off autoplay with a real click if it is on
const auto = page.locator('.ytp-autonav-toggle-button');