Stream system audio through mpd

mpd doesn't accept pulseaudio input sources, so there is no direct way to route pulseaudio through mpd.

However, what you want to accomplish is still possible, with the help of gstreamer and some cleverness. I accomplished this a few years ago.

I wrote this program which implements the "Gstreamer Pipeline Script" component of this diagram:

stream diagram http://tiyukquellmalz.org/sean/stream.svg

To sum up the diagram, here is what happens:

  • mpd reads music files off of the disk, decodes them, and "plays" them to a module-null-sink type audio output of pulseaudio.
  • Any other programs you want to run on your computer that output sound -- Adobe Flash, beeps from the gnome shell, the web browser, etc. also send their audio output to the module-null-sink of pulseaudio (it's made the default audio device of the system).
  • The module-null-sink output has a .monitor source, which lets you take the audio that's pushed out to a null sink and "capture" it back in as if it were an input device (like a microphone).
  • Pulseaudio performs software mixing on the fly of all the audio programs on the entire computer, including mpd, web browsers, and everything else using pulseaudio.
  • The tribblify program that I wrote uses GStreamer to capture the pulseaudio null sink monitor audio, which contains mixed audio of both mpd as well as any other programs on the system; perform MP3 encoding; then stream it to a shoutcast / icecast server. tribblify essentially becomes a "streaming source".
  • The tribblify program automatically detects when mpd changes tags of the playing audio and pushes those tags down the shoutcast stream.
  • The icecast or shoutcast server, which can be on the same computer or a different one, streams out the results to all the connected clients.