Ivan Tkalin

I’m a software engineer. I solve problems.

Broadcasting your rhythmbox in ubuntu 11.10

Once I decided to setup my rhythmbox broadcasting into local network (so my wife or home media player could connect and listen), and didn’t find any comprehensive guide, so I decided to write my own when I managed to configure it.

I found a couple rhythmbox plugins for that, but they didn’t work for me, so I stopped on icecast plus darkice.

Installing and configuring icecast

Icecast is free server software for streaming multimedia. We will use it to create streaming server on localhost.

Installation

sudo aptitude install icecast2

Configuration

  1. Open the file /etc/icecast2/icecast.xml as root and change all passwords in authentication section. You will use source-password to connect darkice and admin-password for admin web-interface.
  2. Change hostname parameter if you want to stream over the internet, or just leave localhost for local network.
  3. To enable icecast daemon, change flag to ENABLED=true in /etc/default/icecast2 file.

Icecast will run on port 8000 (configurable), so you can access admin interface by this url: http://localhost:8000

You can start and stop icecast server using following commands

sudo /etc/init.d/icecast2 start
sudo /etc/init.d/icecast2 stop

Note: if you (like me) don’t want icecast2 to be started automatically, you can disable it:

sudo update-rc.d icecast2 disable

Installing and configuring darkice

DarkIce is a live audio streamer. It records audio from an audio interface (e.g. sound card), encodes it and sends it to a streaming server.

Installation

sudo aptitude install darkice

Configuration

  1. Copy example darkice configuration to your home folder:

     cp /usr/share/doc/darkice/examples/darkice.cfg ~/
    
  2. Open ~/darkice.cfg in your favourite editor and configure like this:

     [general]
     duration        = 0
     bufferSecs      = 1
     reconnect       = yes
    
     [input]
     device          = pulse
     sampleRate      = 44100
     bitsPerSample   = 16
     channel         = 2
    
     [icecast2-0]
     bitrateMode     = cbr
     format          = vorbis
     bitrate         = 320
     server          = localhost
     port            = 8000
     password        = <your-icecast-source-password>
     mountPoint      = sample.ogg
     name            = sample
    

    Note: change <your-icecast-source-password> to source-password from your icecast.xml

    I’m using Ogg Vorbis stream here, but you also can use mp3 stream just change format from vorbis to mp3 and mountpoint to sample.mp3.

  3. Run darkice

     sudo /etc/init.d/icecast2 start
     sudo darkice -c ~/darkice.cfg
    

After that you can connect your clients to url: http://<your-ip>:8000/sample.ogg and they will hear your pulseaudio input.

Streaming your pulseaudio output instead of input

As I said, after all steps above are completed, your clients will hear your input (microphone or line-in) instead of your output. You have several choices here:

  1. Connect your input to your output via audio cable. Most simple, but less flexible solution. No other instruction required for that.
  2. Configure pulseaudio to redirect all your output to darkice input.
  • Install pavucontrol sudo aptitude install pavucontrol
  • Ensure you are running icecast2 and darkice as described above
  • Launch pavucontrol GUI
  • Open the ‘Recording’ tab
  • Find ALSA plugin [darkice]: and change it’s source to Monitor of <your-sound-source> using button near speaker icon
  • That’s it, connect your clients to http://<your-ip>:8000/sample.ogg
  1. Configure pulseaudio to redirect just your rhythmbox (or other player’s) output to darkice. This is what I’ve chosen because I keep all my other sounds in my laptop speakers and stream only music played by rhythmbox. But this will work only if you have several output sources like me (I have main output and HDMI output through my videocard)
  • Install pavucontrol sudo aptitude install pavucontrol
  • Ensure you are running icecast2 and darkice as described above
  • Launch pavucontrol GUI
  • Open the ‘Recording’ tab
  • Find ALSA plugin [darkice]: and change it’s source to Monitor of <your-secondary-source> using button near speaker icon (I’ve chose HDMI here)
  • Open the ‘Playback’ tab
  • Find Rhythmbox section (rhythmbox should be running) and change and change it’s destination to ‘’ using button near speaker icon (I’ve chose HDMI here)
  • That’s it, connect your clients to http://<your-ip>:8000/sample.ogg

That’s it.