A "Silent Bridge" that pipes raw audio data from a Snapcast client directly into an Icecast MP3 stream using a headless Docker container. This setup requires no virtual sound cards or host drivers.
- Input: Connects to a Snapserver as a client.
- Processing: Pipes raw PCM audio from
snapclientdirectly toffmpeg. - Output: Encodes audio to MP3 and streams it to an Icecast server.
- Docker and Docker Compose installed.
- Access to a running Snapserver.
-
Clone the repository:
git clone https://github.com/byrdsandbytes/beatnik-icecast-bridge cd beatnik-icecast-bridge -
Configure Environment Variables: A
.envfile is used to store your configuration. The repository includes a template, but you should create/verify your own:# .env SNAPSERVER_IP=192.168.1.50 # Icecast Configuration ICECAST_SOURCE_PASSWORD=hackme ICECAST_ADMIN_PASSWORD=hackme ICECAST_PASSWORD=hackme ICECAST_RELAY_PASSWORD=hackme # Internal URL for the bridge to connect to Icecast ICECAST_URL=icecast://source:hackme@icecast:8000/stream # Cloudflare Tunnel Configuration (Optional) TUNNEL_TOKEN=your_cloudflare_tunnel_token
SNAPSERVER_IP: The IP address of your Snapserver.ICECAST_URL: The full URL to stream to the internal Icecast server.ICECAST_*_PASSWORD: Passwords for the Icecast server.TUNNEL_TOKEN: Your Cloudflare Zero Trust tunnel token (if exposing via Cloudflare).
-
Build and Run: Use Docker Compose to build the image and start the containers (bridge + icecast) in the background.
docker compose up -d --build
-
Access Stream: The Icecast server will be available on port
8010(to avoid conflicts with other services).- Stream URL:
http://<your-pi-ip>:8010/stream - Admin Panel:
http://<your-pi-ip>:8010/admin/
- Stream URL:
-
View Logs: Check the logs to ensure the connection is established and audio is streaming.
docker compose logs -f
-
Stop: To stop the bridge:
docker compose down
You can securely expose your Icecast stream to the internet using Cloudflare Zero Trust without opening any firewall ports.
For a comprehensive, step-by-step tutorial on setting up your Cloudflare account, creating a tunnel, and extracting your TUNNEL_TOKEN, please see the Cloudflare Setup Guide.
The audio pipeline logic is contained in start.sh:
#!/bin/sh
snapclient -h $SNAPSERVER_IP --logsink stderr --player file | \
ffmpeg -f s16le -ar 48000 -ac 2 -i pipe:0 \
-af "alimiter=limit=0.99" \
-codec:a libmp3lame -b:a 128k -content_type audio/mpeg \
-f mp3 $ICECAST_URL