Replies: 1 comment 2 replies
-
|
Well, I got too cocky. I tried experimenting with snapcast, but had even worse results (constant buffering and choppy audio). The real solution, that actually worksWhat you'll need : ffmpeg. Using a The Now this works extremely well on my setup -- by that I mean I get a 1-second latency using FLAC. AlternativesYou could also use a better suited format for streaming, MPEG-TS, which in theory allows for error and synchronization corrections. However I have not found a significant latency improvement over the FLAC setup. The only way to stream PCM is through an obscure lossless codec, s302m, used for television application. Given that it only supports 48kHz frame rate, it's better to feed it 48kHz audio. Scripting this... Or not, because you don't have to: the nature of UDP means you don't need to have an open connection, so ffplay just keeps on listening on the local port until you shut it down or it gets incorrect data. You have one receiving endpoint that listens to any stream coming from the local network. Depending on the formats, here are the commands, using ffplay: I still got questionsI'm definitely not an expert, so I still havesome lingering questions:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I thought I would share my experience in the case it could be of help to others.
I have a Raspberry Pi attached to the main speaker of my living room. I have 2 computers, a Linux one and a Windows one, which have MPD installed, both using the same synced library.
Here's what I had to do to get the client to receive streams from my machines.
Install MPD on Windows... but on Linux
I couldn't get MPD to work properly on Windows natively.
Using WSL 2, you can easily run an Ubuntu system inside Windows and hence get all of the perks of MPD on Linux without the Windows hassle. Cygwin is a terrible mess that should be avoided.
From my experience, using latest WSL 2 and latest Ubuntu LTS:
/etc/fstab)To control MPD you can also use a Windows client (like Cantata), and connect to localhost:6600 without problem. As sound may not be optimal through ALSA/Pulse, you'd have to use a player (like VLC) to read directly from the HTTP stream. It's a good way to have MPD work on Windows.
You could also of course use any other client on your local network, like MALP on Android, provided your port are set up correctly.
Streaming from MPD on WSL to the local network
To connect to an httpd audio stream from MPD on WSL, here's what you have to do.
To communicate with the outer local network, you need first and foremost to open a port on your Windows firewall. Assuming we're using port 8000 with httpd, type the following in an elevated PowerShell console:
Inside Windows, WSL gets assigned a particular IP adress. We need to create a bridge between the Windows localhost and the WSL IP. The IP identifying WSL on Windows can be found using the following in a PowerShell console:
Example output:
To establish a new Windows firewall rule connecting the two adresses, in an elevated PowerShell console type:
If you think you've made a mistake, delete a portproxy rule using:
Reading the HTTP stream on the client
Depending on your situation, the limiting factor might be computing power (like with an old Raspberry Pi) or bandwidth (unstable network).
If it's bandwidth, use lame.
If it's computing power, use FLAC or WAVE.
twolame is a good compromise, transparent at 320kbps.
In any case you should set a fixed audio format to avoid trouble decoding the stream.
Here are my settings for httpd in
mpd.conf:You should be able to read the stream from any machine on your local network. Here are some working commands depending on the format of the audio stream. These imlply a stable stereo 44100Hz 16-bit stream.
playis asoxcommand.For MP2/MP3 (twolame/lame) :
For FLAC :
For WAVE :
To check the network activity of streaming on the local network, use:
Problems reading MPD HTTP stream
Occasionally, you might encouter some problems reading the stream: sometimes the decoder and the stream are out of sync, that is the decoder decodes faster than the speed at which the stream gets sent. This causes the player to buffer frequently, causing stuttering in the audio output.
As I understand it, it's a very hard problem to solve. A reboot of the machines may be your best hope. Hopefully it happens rarely in my case, and a Windows reboot always solve the issue. Tweaking the player to fix the issue (e.g. by increasing the buffer) will only offset the problem. Whether you're using sox, (c)vlc, flac, ffplay or mpg123, you shouldn't need to tweak the settings for an optimal experience.
See this detailed commentary for more information: #1063 (comment)
If you keep having this problem, you might want to switch to IceCast or SNAPcast as a streaming solution.
https://mpd.readthedocs.io/en/latest/plugins.html#shout
https://mpd.readthedocs.io/en/latest/plugins.html#snapcast
Scripting this
On the client (here my Raspberry Pi), a program probes the stream every 330ms and start playing when it's on:
Hope this will help some!
Beta Was this translation helpful? Give feedback.
All reactions