Broadcasting desktop audio as (local) internet radio

I recently used Icecast and GStreamer to stream music playing on my Linux desktop to an old internet radio that does not have Bluetooth. In case someone finds themselves in a similar situation, here are the commands:

Icecast installation & configuration

On ArchLinux, simply sudo pacman -S icecast. Then, change the configuration file /etc/icecast.xml:

  1. Change the passwords to make sure no-one else can stream on your server (you can search and replace the string “hackme”, as that is the default password)
  2. Adapt the <bind-address> so that the station is only accessible from your local network. Set this to your local IP, usually something that starts with “192.168.”

Finally, you can start the server with systemd: systemctl start icecast

GStreamer setup

Find out the Pipewire monitor of your output with pactl list sources. Look for a device with the description “Monitor for …”. Then, take note of its name and replace it in the gstreamer command below.

You’ll need gst-plugins-good for the MP3 encoder and shoutcast plugin. To start streaming, use gst-launch. Replace the pulseaudio device, IP address and password below with the values you configured earlier.

gst-launch-1.0 \
        pulsesrc device=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor \
        ! audioconvert \
        ! lamemp3enc \
        ! shout2send mount=/stream.mp3 port=8000 \
                     username=source password=hackme \
                     ip=192.168.X.Y

Conclusion

If everything worked, you know should be able to hear whatever is playing on your desktop under the stream http://192.168.X.Y/stream.mp3.m3u. There are two things you should keep in mind:

Comments

To add a comment, write an email with this link.