Streaming Audio with Ices and Icecast

Retransmit from a radio scanner to the Internet via Ices and Icecast.
Ices Configuration

My encoding computer is also running Mandriva. Because this machine is running only at 233MHz with 64MB of RAM, I decided to do a minimal install and leave off the window manager. Ices is also available from the contrib repository. So once again, typing urpmi ices is all it took to install Ices. However, you can download the latest releases from the Ices Web site (see Resources). Make sure you use the 2.0 series if you want to use Ogg. It also requires that libshout is installed. Once you have that, you can extract the archive and run ./configure; make; make install to get everything installed.

The Ices configuration file is also an XML file. It is usually stored in /etc/ices.conf.

The beginning of the configuration file has some settings that dictate how Ices runs. It can be helpful to change these during the initial setup, so that Ices runs in the foreground and sends messages to the console. These messages can be very helpful in debugging problems on initial setup. Once everything is set up and running, make sure Ices runs in the background and logs messages to a file:


<background>1</background>
<logpath>/var/log/ices</logpath>
<logfile>ices.log</logfile>
<loglevel>3</loglevel>
<consolelog>0</consolelog>

The rest of the file is under the stream section. This is where you configure settings specific to this particular audio stream. Within the stream section, the metadata section is where you specify information about the stream. This information will be displayed on the Icecast Web page:


<metadata>
    <name>W0ZWY 146.895 MHz</name>
    <genre>Live</genre>
    <description>Live feed of the 
        W0ZWY repeater</description>
</metadata>

The input section is the place to define where the audio actually comes from. There are many possibilities, including options for playlists and scripts. Because I want to encode live audio, I used the oss module. Don't be alarmed if your system uses the ALSA sound system instead of OSS. ALSA has OSS compatibility, so this module works with both ALSA and OSS. Use the device parameter to specify the sound device from which to get data. On most systems it will be /dev/dsp. The rate parameter specifies the sample rate of the data in hertz. Most devices use 44100. Use the channels parameter to specify the number of channels available for capture. For most devices this will be 2 (stereo):


<input>
    <module>oss</module>
    <param name='device'>/dev/dsp</param>
    <param name='rate'>44100</param>
    <param name='channels'>2</param>
</input>

The instance section allows you to specify the number of instances of this stream. You might have more than one instance if you want to send the stream to more than one server, or if you want to have different versions of the same stream at different bitrates. For my system, I want only one instance.

The first part of the instance section is where you specify the streaming server information. The hostname tells Ices where to send the data. The port and password must match the values you specified in the Icecast configuration file. The mount option specifies what the name of the stream will be called.

The encode section specifies how the audio will be encoded. The easy way to do it is to set the sample rate and channels to match the input section above. But, I didn't need that much quality for my stream. So, I used the downmix and resample sections to tell Ices to resample the audio to 11127Hz and downmix it to 1 channel (mono). There are two options you can use to adjust the final bitrate of the stream: quality and nominal-bitrate. Notice that I commented out nominal-bitrate and set quality to 2:


<instance>
    <hostname>192.168.1.1</hostname>
    <port>8000</port>
    <password>hackme</password>
    <mount>/146.895.ogg</mount>

    <encode>
        <quality>2</quality>
        <!--nominal-bitrate>32000</nominal-bitrate-->
        <samplerate>11127</samplerate>
        <channels>1</channels>
    </encode>

    <downmix>1</downmix>

    <resample>
        <in-rate>44100</in-rate>
        <out-rate>11127</out-rate>
    </resample>
</instance>

Once the configuration file is all ready, make sure that Ices has permission to access the audio device through /dev/dsp. Mandriva creates an audio group, which owns the /dev/dsp file. It also creates an ices user and group when ices is installed. I simply added ices as a member of the audio group in the /etc/groups file by editing the audio group:

audio:x:81:ices

Finally, you can start Ices by running the init script: /etc/init.d/ices start. If there are any errors during startup, look in the log files to debug them. It also can be helpful to examine the Icecast log files on your streaming computer to debug problems.

Once everything is up and running, you can access the Icecast status page on the port you specified in the configuration file. Figure 3 shows an example of an Icecast status page. Clicking on Click to Listen launches your audio player.

Figure 3. Icecast Status Page

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Out of date

Paul Duncan's picture

Hi,

I suggest removal of this article. It seems that things have moved on so much, that all it does is waste people's time. I need to do *exactly* what this guy is doing, but I can't follow the procedure here as the software has changed significantly in two years.

Best Regards,

Paul
~~~~~

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState