Fandom

Music Player Daemon Community Wiki

Icecast2

525pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

There is already sufficient documentation on how to setup MPD to stream to icecast. This document only explains on how to maintain a persistent stream even if Music Player Daemon stops or pauses playback. At least on Debian Lenny (mpd 0.13.2, icecast2 2.3.2) icecast will disconnect listeners once this happens. The solution is to setup a fallback stream using a silent OGG Vorbis audio file on your icecast2 server. Before you attempt the below, please follow the Documentation on how to setup MPD for icecast streaming.


Configuring MPD Edit

I took this directly from the MPD configuration documentation. If you followed the steps there, your mpd.conf should include the following:


################# SHOUT STREAMING ########################
#
# Set this to allow mpd to stream its output to icecast2
# (i.e. mpd is a icecast2 source)
#
audio_output {
        type              "shout"
        name              "my cool stream"
        host              "localhost"
        port              "8000"
        mount             "/mpd.ogg"
        password          "IceCast_mpd"
        quality           "5.0"   
        format            "44100:16:1"
        user            "source"
} # end of audio_output
##########################################################


Configuring Icecast2 Edit

The main configuration file for icecast2 is /etc/icecast2/icecast.xml. In the default configuration file you will first need to change at least the username and password for the source client:


<authentication>
        <!-- Sources log in with username 'source' -->
        <source-password>IceCast_mpd</source-password>
        <relay-password>someRelayPassword</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>someAdminPassword</admin-password>
</authentication>


I found the other default settings to work fine for me. However, we need to setup a mount section to setup the fallback stream. Find the following lines:


<!-- Only define a <mount> section if you want to use advanced options,
         like alternative usernames or passwords


And insert the mount-section before this line (since that line starts a comment, if you know your way around with XML, you can of course change the comment or uncomment the section that follows and adapt it. This is what you will need at the least:


<mount>
        <mount-name>/mpd.ogg</mount-name>
        <fallback-mount>/silence-fallback.ogg</fallback-mount>
        <fallback-override>1</fallback-override>
</mount>

The mount-name is the same as you specified in your mpd.conf. The fallback-mount is actually an ogg-file that we are going to place in icecast's web-root in a minute. The fallback-override option specifies that icecast will take you back to MPD once it resumes streaming.


The fallback-mount refers to a file silence-fallback.ogg. In theory this could be any silent ogg stream but in practice a number of problems can arise if this file is too short or encoded with a very low bitrate.


Creating a silent stream Edit

I used Audacity to do this. There might be easier ways. If you use Audacity, you can easily open the Generate menu -> Silence and select how long the silence should be (I recommend about 30 seconds). Hit File->Export and save the file as WAV.


It's tempting to export the file directly to OGG but that can cause problems. It seems like the export dialog only allows you to specify a Quality setting for OGG. However, even with a high quality, silence can be compressed very well in OGG. Thus, if your listener uses a large buffer (I use mplayer with 1024kbit), the silence stream is cached again and again leading to an extreme lag once MPD resumes streaming. The solution is to encode the file with a minumum or average bitrate.
The silent WAV can now be converted to a 384 kbps OGG file:


oggenc -b 384 -o silence-fallback.ogg silence-fallback.wav

Silent OGG Vorbis files can also be created directly (without recording anything) like this:

dd if=/dev/zero bs=176400 count=5 | oggenc - -r -o silence.ogg

This creates a 5 second silent audio clip in OGG Vorbis format. I actually had trouble when using longer clips. 5 seconds works for me.

Some users may need to additionally specify a minimum (-m) and maximum (-M) bitrate equal to their stream. Some clients go nuts if you don't.

dd if=/dev/zero bs=176400 count=5 | oggenc - -r -m 128 -M 128 -o silence.ogg

Substitute the 128 for your stream bitrate.

Final Steps Edit

The resulting silence-fallback.ogg should now be placed in icecast's webroot, which on Debian systems is located in /usr/share/icecast2/web/.


Restart your icecast2 and mpd services and you should be all set.

Also on Fandom

Random Wiki