LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Configuring clients for mpd server (https://www.linuxquestions.org/questions/linux-networking-3/configuring-clients-for-mpd-server-4175608187/)

Beren329 06-19-2017 09:09 AM

Configuring clients for mpd server
 
Hello All!

I have a question regarding mpd and ncmppcpp[cppcpppppcppppppp] that I hope someone might be able to help with. I'm new to setting up both.

Here's the situation: in trying to repurpose rather than junk a number of old gadgets I have lying around, I'm working creating a simple household digital music server. The idea is to use an old netbook with an external drive as the server, and then stream music from there to every other device in the house, including a few old phones that'll become players/remotes.

So, I did a headless Debian install on the old netbook, which is connected to an external HD containing many gigs of music. I'm using mpd as the server, controlled locally via ncmpcpp. That part works great.

On the android phones/tablets, I'm using MPDroid, which works beautifully: each of those devices both works as a remote for the main system *and* can pipe the audio directly to the device. So, for example, an old phone hooked up to a radio/portable speaker in the kitchen can stream music from the server to the kitchen radio.

What I'm having trouble with, a little ironically, is doing the same things (both controlling the server AND streaming the audio *to* the remote computer) to my other linux boxes (a laptop and a desktop) that run Linux using ncmpcpp!

I've been able to get it to work in a way that seems awfully kludgy to me:

The "server" is configured to stream on port 8000; the main port specified in mpd.conf is 6601`

1. Run mpc on the client to connect it to the httpd stream coming from the server:

Code:

mpc add http://10.0.0.205:8000
2. Then run one instance of ncmpcpp that just pipes in the audio from that stream.

3. Then run *another* instance of ncmpcpp on the client, pointing it to port 6601, which allows one to control and select music on the server from the client:

Code:

ncmpcpp --host 10.0.0.205 --port 6601
This *does* work, but it seems like a really awkward solution to me, and I fear I'm missing something stupidly obvious. Would anyone have any suggestions?

Thanks!

Mark in St. Paul MN

ondoho 06-22-2017 01:39 AM

i'm surprised you got it working at all.
i have been told that mpd can be remote-controlled, but is not really suitable to stream music to other devices.
:hattip:

i'm guessing your setup would not work for remote streaming? meaning, when you leave your house (home network)?

273 06-24-2017 11:37 AM

Just set up mpd to output a stream, then open something like VLC on the device which you want to listen on and pint it at the IP address and port. Then open ncmpcpp with something like "ncmpcpp -h <ipofstreamingserver>" and you'll be able to control it.
The key thing to remember is that mpd doesn't output to network by default -- it is set up to be controlled over a network and run on a headless device with speakers attached.

273 06-24-2017 02:25 PM

I finally* bothered to find out why mpd stopped working on my machine** and found that the http streaming section of mpd.conf is easy enough to populate and that encoding as wav didn't work so well on my wireless-attached laptop but streaming as flac is fine though, of course, if you're just streaming for background music vorbis or lame will be fine and even less bandwidth-intensive. I listened to the stream using:
Code:

mplayer http://192.168.1.12:8000
Where the IP addresses is the server IP. Then connected ncmpcpp to it in another terminal window with:
Code:

ncmpcpp -h 192.168.1.12
For completeness the streaming section of the mpd.conf looks like this on my machine:
Code:

audio_output {
        type            "httpd"
        name            "My HTTP Stream"
        encoder        "flac"          # optional, vorbis or lame
        port            "8000"
#      quality        "5.0"                  # do not define if bitrate is defined
#        bitrate        "128"                  # do not define if quality is defined
        format          "44100:16:2"
}

*It's not been working for months and I don't really listen to music with any other player as they're not as convenient so shows how lazy I am.
**I kept on getting an error that mpd was unable to decode the given file -- turns out that while, on my reinstalling Debian a while back, I hadn't removed the folder that I was pointing mpd to for my music collection but the simlinks in it stopped being valid.

Beren329 06-24-2017 06:07 PM

Thank you 273!

I'd discovered the VLC solution independently, and indeed it's a little more elegant than what I was doing. I also realized it makes more sense, as far as controlling the stream goes, to just SSH into the server and run ncmpcpp there.

Thanks for the flac suggestion, though--sound quality is really important to me, and most of my music is in FLAC format anyway, so streaming with flac as the encoder is a great idea!

Mark

273 06-24-2017 06:15 PM

Glad you've got things working as you like them.
I wouldn't bother sshing into the server and running ncmpcpp there unless you're worried about leaving mpd open on the network -- using a remote client is just as easy. Not sure whether you're aware of Gnome Music Player Client either? It's not a bad controller and is installable as gmpc in Debian.
I don't recall whether VLC will keep listening when the music stops, I know mplayer doesn't otherwise I would suggest mplayer might be better as it's just a command line. Mind you, anything you can listen to a music stream with will work.
Streaming as FLAC is still fairly high overhead but it's worth trying and more likely to work than wav.
In case you can't tell I've been a great fan of mpd ever since I first got it working (which took me ages due to PulseAudio permissions and the like). I was impressedto find it can even play network streams itself and stream to icecast servers to make one's own "internet radio station".

Beren329 06-24-2017 06:29 PM

I'm totally learning why you'd be enamored with mpd--simple, high-quality, and really useful. I'm also rather enamored of ncmpcpp--love the retro look of the console-only visualizer, for one thing! This is also, of course, a subset of a sort of process of falling in love with the command line and terminal for all sorts of things.

273 06-24-2017 06:44 PM

Indeed, it's frustrated me a lot because, to me at least, it's one of those situations where a simple tool makes you have to actually think about what you are setting up. So have to admit that, sometimes, I just feel like using things like Gnome Music Player Client.


All times are GMT -5. The time now is 10:24 AM.