Skip to content

Commit 9a878ab

Browse files
CopilotZozman
andcommitted
Fix browser UI and audio routing - hide chrome and route audio to capturable sink
Co-authored-by: Zozman <1192364+Zozman@users.noreply.github.com>
1 parent c64b6c4 commit 9a878ab

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Setup base
2-
FROM golang:1.24.5-alpine AS base
2+
FROM golang:1.23-alpine AS base
33
WORKDIR /app
44
COPY ./go.mod ./
55
COPY ./go.sum ./

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/Zozman/stream-website
22

3-
go 1.24
4-
5-
toolchain go1.24.5
3+
go 1.21
64

75
require (
86
github.com/chromedp/chromedp v0.11.2

main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ func streamWebsite(ctx context.Context, config *Config) error {
110110
chromedp.Flag("use-fake-device-for-media-stream", true),
111111
chromedp.Flag("alsa-output-device", "pulse"),
112112
chromedp.Flag("enable-features", "VaapiVideoDecoder"),
113+
// Hide browser UI for clean streaming
114+
chromedp.Flag("kiosk", true),
115+
chromedp.Flag("disable-infobars", true),
116+
chromedp.Flag("disable-automation", true),
117+
chromedp.Flag("disable-restore-session-state", true),
118+
chromedp.Flag("disable-background-networking", true),
119+
chromedp.Flag("no-first-run", true),
113120
chromedp.WindowSize(config.Width, config.Height),
114121
)
115122

@@ -162,8 +169,8 @@ func startFFmpegStream(ctx context.Context, config *Config, display string) erro
162169
"-video_size", fmt.Sprintf("%dx%d", config.Width, config.Height),
163170
"-framerate", "30",
164171
"-i", display,
165-
"-f", "alsa", // Use ALSA for audio capture (FFmpeg supports this)
166-
"-i", "default", // Use ALSA default device (configured to route to PulseAudio)
172+
"-f", "pulse", // Use PulseAudio directly for better audio capture
173+
"-i", "stream_output.monitor", // Capture from the monitor of our stream sink
167174
"-c:v", "libx264",
168175
"-preset", "veryfast",
169176
"-tune", "zerolatency",

start.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ mkdir -p $PULSE_RUNTIME_PATH
3333
pulseaudio --start --log-target=syslog --system=false &
3434
sleep 3
3535

36-
# Create a null sink for audio output
37-
pactl load-module module-null-sink sink_name=null_output sink_properties=device.description=Null_Output 2>/dev/null || echo "Failed to create null sink"
36+
# Create a null sink for audio output that can be monitored
37+
pactl load-module module-null-sink sink_name=stream_output sink_properties=device.description=Stream_Output 2>/dev/null || echo "Failed to create stream sink"
3838

39-
# Set the null sink as default
40-
pactl set-default-sink null_output 2>/dev/null || echo "Failed to set default sink"
39+
# Set the stream sink as default so browser audio goes there
40+
pactl set-default-sink stream_output 2>/dev/null || echo "Failed to set default sink"
41+
42+
# Create a loopback from the sink monitor to make it available for capture
43+
pactl load-module module-loopback source=stream_output.monitor sink=stream_output latency_msec=1 2>/dev/null || echo "Failed to create loopback"
4144

4245
# Create ALSA configuration that uses the default PulseAudio device
4346
cat > /root/.asoundrc << EOF
@@ -55,6 +58,8 @@ echo "PulseAudio sinks:"
5558
pactl list short sinks 2>/dev/null || echo "PulseAudio not running"
5659
echo "PulseAudio sources:"
5760
pactl list short sources 2>/dev/null || echo "No PulseAudio sources"
61+
echo "PulseAudio modules:"
62+
pactl list short modules 2>/dev/null || echo "No PulseAudio modules"
5863
echo "ALSA devices:"
5964
aplay -l 2>/dev/null || echo "No ALSA playback devices found"
6065

0 commit comments

Comments
 (0)