22 October

How to create an Icecast Broadcasting Station on OS X

This post discusses how to distribute music to a collection on locations around a single house, but it works equally well for distributing music across the internet since it involves creating an internet-based streaming "radio station" using icecast, as well as Airtunes.

iTunes being streamed in from icecast

Last weekend my wife Krys threw a party for me. Like any party you have yourself, it was a bit frustrating since there is so much greeting and running around to do that I didn't get much chance to spend much quality time with anybody, and everybody there was somebody I would have liked to sit and talk to.


I had hoped to get people dancing (and failed), but as an aside I arranged to broadcast music around the house to several locations on 2 floors. To do this, I used iTunes (on a Mac) to produce a playlist. The problem then, was how to distribute a synchronized playlist to at least 3 locations within the house. As an aside, I wanted to use icecast (i.e. shoutcast) so I could do other stuff as well like (later on) broadcast outside the house. The Shoutcast protocol can be used to broadcast to Macs, Windows, Linux, FreeBSD and Solaris (and more). Shoutcast is freeware while the compatible Icecast (or Icecast2) is true GPL (and I believe it was released before Shoutcast became free).

Option 1: Use Airport Express: The easiest way to do this is to use airport express wireless "bricks". You can broadcast to these easily from iTunes, and it it just works. My problem was that I didn't have enough Airport Express bricks; some locations had to be actual computers, but iTunes does not support broadcasting to another computer.

Airtunes Setup within iTunes

Option 2: Use Airfoil: There is a software package called Airfoil. This allows you to capture the audio output (from any program) and broadcast it to an Airport Express unit, or to a mac or Windows computer running their free Airfoil Speakers application. It's very nice and only costs $25. Being a bit of a hard-core hacker, I was interested in an icecast solution I could roll myself, for several reasons including the fact it would allow me to subsequently broadcast content over the internet, for example to my office.

Option 3: Roll my own Icecast2 server: this is obviously what I chose to do. It turned out to be a lot harder to figure out than I expected and had I been less reluctant to admit defeat and more practical, I would simply have purchased Airfoil. On the other hand, it's pretty easy once figured out and I needed some hacking-based stress relief. Read on for the recipe.

How to create an Icecast Broadcasting Station on OS X

Internet streaming radio is normally based on Shoutcast or the compatible GPL software called Icecast. Icecast software runs on Apple's OS X as well as Linux an it's what I used. This method can also be using with Airtunes (normal iTunes bradcast to Airport Express) at the same time.

Requirements: OS X, Apple Developer tools, http://www.macports.org/. If you use my precompiled binaries (below) you might get away with all these tools if you are lucky.

To feed content into Icecast, you need one of several programs depending on the format(s) you plan to use (such as MP3 or Ogg Vorbis) I selected Darkice and the MP3 format since I had prior experience with darkice, and like the universality of mp3, and because darkice runs on Linux and OS X, and is pretty solid.

Darkice pulls in data from either a fixed file, or from an input device (like a microphone). I was using iTunes so I needed to re-route the output from iTunes to create a vartual input device for darkice to listen to. To do this,
I used a pair of tools I discovered. This learning process sucked time, but was quite useful for other projects. To do this I used Soundflower and Jack. Soundflower grabs and input (or output) and Jack allows the output from Soundflower to to connected as a virtual input to ay other program.
Soundflower V 1.3.1 is available via macupdate.com/ or thirdcog.eu. Jack is available at http://jackaudio.org/ and can be downloaded directly from Sourceforge.

A diagram illustrating all this is shown here.

Setup of components used for broadcasting

Note that darkice and icecast2 have slightly complex-looking XML setup files, but nothing exotic needs to be done in the setup. Example setup files provided
here should work fine for you, and they're called icecast.xml and darkice.cfg.

To configure and control Soundflower, which is a kernel module, you should use the application program (app) called Soundflowerbed. The program Jackpilot that comes with Jack can be used to control it, but all you actually need to do with it is start Jack. WARNING: I also tried to install Jack using macports as a command-like tool, but the resulting code was incompatible with darkice and had to be completely removed to get things working!

To install darkice and icecast2 you can use macports (i.e. port install darkice and port install icecast2). If you don't know about macports, you should. If you can't figure that out, then this approach isn't for you anyhow, and you should buy Nicecast and/or Airfoil.

How to make it go:

In the normal Sound control panel, set the output to be Soundflower (2ch). With soundflowerbed, you can optionally route the 2ch audio to the hardware output device (speakers) as well, to help you hear what's happening.

Run Jackpilot and start Jack.

Run icecast using:

icecast -c icecast.xml &

Run darkice from the terminal using:

darkice -c darkice.cfg &

Play music with iTunes.

Listen to it from another computer using iTunes by using the Menu item Advanced>>Open Audio stream
and enter something like with the number should be replaced by the IP address or name of the computer doing the broadcast.

Extra notes

Instead of Soundflower it seems like you can use ESD, the Enlightnment Sound Daemon (which is commonplace on Linux). These posts provide an alternate solutions based on esd.

  • Rolf Haynberg provides an approach that is much simpler since it doesn't doesn't use the (standard) shoutcast protocol, and is thus is much more limited in my opinion, but if you only want to broadcast to one or two Macs, this is a easier solution.

  • Related content on using esd is also available at this page on macosxhints.com

  • Darkice config files are explained here.

    Pre-Compiled versions of darkice and icecast for OS X Leopard are available here is you want to try skipping their installation (they were compiled for OSX 10.5.5 and may not work if your computer is configured differently from mine.)

    Soundflower is also available at cycling74.com and they appear to be the original developers, but only provide an older version.

    The full scoop on Icecast, from installation to history can be found in the on-line book by Kerry Cox.

    In you get into Internet radio, a list of stations can be found at dir.xiph.org (in addition to those built into iTunes).

    Audio Hijack can also be used to capture audio on OS X.

    [ Followup, Feb 2010: for Snow Leopard, you may want to install Jack version 0.83 or better.

    Be careful with a combination of multiple jack installations.. The dmg from the Jack web site installs jack in one place (/usr/local) while the macports version installs it someplace else (/opt/local). If both are installed you can end up with strange problems, like a version of darkice that has a problem opening jack and doesn't work. ]

    Another blogger has provided a very clear page on this process with some additional details http://blog.joshdzielak.com/blog/2012/11/21/live-stream-audio-from-osx-mountain-lion-with-icecast-and-darkice/

    By Gregory Dudek at | Read (3) or Leave a comment |    
    Re: Broadcasting music to multiple speakers

    wow! this is cool stuff! I'm going to have to try this in my house at school or at home!

    Posted by: Brian at June 04,2009 16:16
    Re: Broadcasting music to multiple speakers

    darkice on macports?

    It doesn't seem to be there at this time.

    I tried compiling darkice manually, but it appears that it needs the macports version of jack, which you said doesn't work...

    Any ideas?

    [ Greg's reply:

    OK, I can't explain how I seem to have claimed to use macports, yet there is no sign of darkice within macports. I think I goofed in the claim I used macports since I see that I have a source tree and compilation residue of macports. In short, it looks like I compiled it from source.

    Re. Jack, I think I installed "jackpilot" (which includes Jack).



    Posted by: the_case at September 10,2009 15:39
    Re: Broadcasting music to multiple speakers

    This is exactly what I'm looking for. Are you still using this setup?


    [ Greg's reply: I use the setup occasionally when I have people over or need distributed music for some reason. It works consistently, although I always need to refer to this post to remind myself how to set it up. ]

    Posted by: mbalders at November 22,2010 23:29
    Please send trackback to:/blog/140/tbping
    There are no trackbacks.
    Post your own response

    Each comment is manually screened for the presence of appropriate and substantive content, due to a constant onslaught of comment-spam. This means there may be a delay before your comment appears.

    (Some kind of name is required, will be visible)

    Required, whatever you enter will be visible to other users.

    (Optional, used for "mailto" link)

    Your email address is not required, but if you insert it it will be displayed so people can contact you.

    Answer this question correctly to demonstrate that you are not a dumb spambot.

    The title for your comment.

    Your comment goes here. All relevant comments are welcome, except for those that simply promote an irrelevant product or else are used to fraudulently inflate the link count to an irrelevant web page. They appear after moderation. Don't forget to also fill in the captcha below or your text will be rejected automatically!

    You must answer this question to prove you are human
    The governator said (when in a movie as T2): 'I'll be ... (pick a number): 1:tuckered, 2:broke, 3:back, 4:broken, 5:swartzneggered, 6:eaten, 7:you?

    Answer this question correctly to demonstrate that you are not a dumb spambot.