Title: mpd And icecast setup Subject: How To setup streaming audio with Music Player Daemon and Icecast on gentoo. #----------------------------------------------------------------------- # MPD will have some local storage of music in /mpd/music # MPD will be configured with 2 audio_output secions # one will output to locally attached speakers # one will output to a stream managed by icecast called /mpd.ogg # Icecast will stream data sent to mpd.ogg to anyone listening for the stream # Client player will tune into the the stream via: http://host:8000/mpd.ogg # Note: mpd.ogg doesn't really exist. # Note: when the stream ends, static.ogg will startplayin so that the stream doesn't end. #---------------------------------------------------------------------- # # Set mpd use flags # echo 'media-sound/mpd aac alsa flac iconv ipv6 ogg oss unicode vorbis ao audiofile mp3 icecast jack pulseaudio' >> package.use # # Install mpd stuff # emerge media-sound/mpd media-libs/libmpd dev-python/python-mpd # # After I'm all done this is what is installed # eix -I mpd [I] dev-python/python-mpd Available versions: 0.2.0 ~0.2.1 Installed versions: 0.2.0(12:13:44 11/02/08) Homepage: http://pypi.python.org/pypi/python-mpd/ Description: Python MPD client library [I] media-libs/libmpd Available versions: 0.15.0 ~0.15.0-r1 ~0.16.1 Installed versions: 0.15.0(11:58:14 11/02/08) Homepage: http://gmpcwiki.sarine.nl/index.php/Libmpd Description: A library handling connection to a MPD server. [I] media-sound/mpd Available versions: 0.13.0 0.13.1 0.13.2 ~0.14.0_pre20081015 {aac alsa ao audiofile avahi flac icecast iconv ipv6 jack libsamplerate mikmod mp3 musepack ogg oss pulseaudio unicode vorbis wavpack} Installed versions: 0.13.2(12:22:57 11/11/08)(aac alsa ao audiofile flac icecast iconv ipv6 jack mikmod mp3 ogg oss pulseaudio unicode vorbis -avahi -libsamplerate -musepack) Homepage: http://www.musicpd.org Description: The Music Player Daemon (mpd) # # Setup music directory # mkdir /mpd/{lyrics,log,database,state,music,playlists} chown -R mpd:audio /mpd # # mpd config # cp /etc/mpd.conf /etc/mpd.conf.orig cat > /etc/mpd.conf <<'END_MPD' ######################## REQUIRED PATHS ######################## music_directory "/mpd/music" playlist_directory "/mpd/playlists" db_file "/mpd/database/database" log_file "/mpd/log/mpd.log" error_file "/mpd/log/mpd.error.log" ################################################################ ######################## OPTIONAL PATHS ######################## pid_file "/var/run/mpd/mpd.pid" state_file "/mpd/state/state" ################################################################ ######################## DAEMON OPTIONS ######################## user "mpd" bind_to_address "any" port "6600" ################################################################ ########################## AUDIO OUTPUT ######################## audio_output { type "alsa" name "My ALSA Device" } audio_output { type "shout" name "My Shout Stream" host "localhost" port "8000" mount "/mpd.ogg" #"/music" quality "5.0" format "44100:16:1" user "source" # optional password "icecast" description "My Stream Description" # optional genre "jazz" # optional public "yes" # optional } ################################################################ ############################# MIXER ############################ mixer_type "alsa" mixer_device "default" mixer_control "Master" ################################################################ END_MPD # # Start it up # /etc/init.d/mpd start # # View the logs # tail -f /var/log/mpd/*.log # # Start by default # rc-update add mpd default # # Install icecast # net-misc/icecast eix -I icecast [I] net-misc/icecast Available versions: 2.3.1-r1 ~2.3.2 {speex ssl theora yp} Installed versions: 2.3.1-r1(16:26:01 11/02/08)(theora -yp) Homepage: http://www.icecast.org/ Description: An opensource alternative to shoutcast that supports mp3, ogg (vorbis/theora) and aac streaming # # Fix perms on log directory # chown -r icecast:nogroup /var/log/icecast/ # # Download this static ogg file, to be used when mpd runs out of music # wget http://gashcrumb.homelinux.org/logahead/files/static.ogg mv static.ogg /usr/share/icecast/web/ # # Configure icecast # cp /etc/icecast2/icecast.xml/etc/icecast2/icecast.xml.orig cat > /etc/icecast2/icecast.xml <<'END_ICECAST' 100 2 5 524288 30 15 10 0 65535 icecast icecast admin icecast 192.168.0.132 8000 /mpd.ogg 3 /static.ogg 1 /usr/share/icecast /var/log/icecast /usr/share/icecast/web /usr/share/icecast/admin access.log error.log 4 10000 0 icecast nogroup END_ICECAST # # start icecast (It took a long time to get my config correcttose this stuff) # /etc/init.d/icecast start lsof -i tcp -nP |grep 8000 icecast 22545 icecast 4u IPv4 461686 TCP *:8000 (LISTEN) # # Start icecast by default # rc-update add icecast default # # View the logs # tail -f /var/log/icecast/*.log # # Use your favorite mpd client to start playing something # I like phpMp2 or relaxx # # Try to stream using remote machien # mplayer http://192.168.0.132:8000/mpd.ogg # # If that doesn't work, try the static.ogg # mplayer http://192.168.0.132:8000/static.ogg # # Checkout the icecast web interface # http://192.168.0.132:8000/admin/listmounts.xsl # # mpd must start after icecast # Add to /etc/init.d/mpd vi /etc/init.d/mpd # Add: need icecast