New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Look into adding a gstreamer fifo sink #775
Comments
Where did this go? will this be added to the main package? |
This isn't being worked on as we would need to convert it to GStreamer 1.0, and all my experiments with that so far have uncovered problems when doing custom elements in python. There are other ways of maybe solving it all, but not something I have time to work on. |
I'd like to see FIFO support added :) |
I just found this searching for a way to get ncmpcpp's music visualizer to work with mopidy. I am in favor. |
Yes, that's the same reason why I found this. It would be really great to 2014-11-06 2:19 GMT-05:00 Blake notifications@github.com:
|
There are gstreamer visualisation plugins, can you not just use those? Yes, that's the same reason why I found this. It would be really great to 2014-11-06 2:19 GMT-05:00 Blake notifications@github.com:
— |
Note that those are on their way out in the next release. |
Is there someone working on this? Would be really nice to be able to use the ncmpcpp visualizer with mopidy. |
Not that I know of, and we likely don't want to do this as GStreamer element as it would block our migration to GStreamer 1.x. |
This is IMO also blocked on adding back proper support for outputs. |
Just adding that I also came across this issue when trying to add visualizer support to Mopidy/ncmpcpp. Would love to have this in the future even if it's not being worked on currently. I'd also like to extend my utmost respect for those who contribute their time to open source projects. 😄 |
Ideally this would work remotely. Mopidy's power lies really in being a solution that can be in your private cloud. |
In general, FIFOs are not a very portable method of interprocess communications and should be avoided IMO. They also have some nasty side-effects, already mentioned in this thread. I think you are better off dumping your packets out using a UDP sink personally....that's a more generic solution and can easily be adapted to something that writes to a FIFO (if necessary) outside of Mopidy....it's a single line of shell script to read data from a UDP port (using netcat) and write it to a FIFO. |
That sounds good. May be clients lie ncmpcpp would also allow using that as input. Another idea is to use PulseAudio directly as it would require no extra implementation on Mopidy's side. The Docker container I made uses TCP to access PulseAudio over network. ncmpcpp could actually use that directly. |
From what I've read, the visualizer is just running an FFT on blocks of samples which are read from a FIFO file. The point I am making is that you can create a FIFO outside of Mopidy using To achieve what you're aiming on Mopidy requires no implementation effort since you can change the audio output property to output to a udpsink GStreamer element. More likely you would want to arrange it as part of a "tee" which outputs to both your ALSA/Pulse sink and the udpsink. |
The following should work....not tested so might need some tweeking. In Mopidy audio configuration:
On your Linux host, launch netcat to listen on localhost for UDP data on port 5555 and output the samples to the FIFO:
In your mpd.conf:
|
Note: If you are using a PulseAudio output, it might be possible to do something similar with its TCP direction connection module. However, you might need to reverse engineer any protocol it runs over the top of the TCP connection e.g., it might not be possible to treat it as a raw sink. |
Thank @liamw9534 for sharing. It would have taken me a while to understand the config enough to do that or even know I could. I'll try to add that to the Docker container see if it works. |
This might run into issues if you don't have something emptying the fifo though. As netcat will fill the kernel buffer and then fail. And depending on how the FIFO is opened you might also run into issues as FIFOs can require a reader to be present to be writable :/ |
But you could adapt my FifoStreamer code to accept the UDP data and handle this for you as I hopefully already have handled most of the error cases you can run into there. |
@adamcik If you have a working script I'd be glad to include it as part of docker-ncmpcpp for people to use. I'd also change docker-mopidy to broadcast on UDP by default using the output trick above. |
I did some basic experiments on the command-line and it all works fine provided you use a connection timeout e.g., The above command works irrespective of whether or not anything is reading from the FIFO file and also works if the process reading from the FIFO file stops and closes the file. |
@wernight see the description of this bug, that is all the code I have. |
And just for belts and braces, I would stick the command in a while loop e.g., |
@liamw9534 You have a mpd.conf there. I am confused by this. You are running a standalone MPD server in addition to mopidy-mpd? |
@lrvick yes my mistake, was of course thinking about config that needs to be added to ~/.ncmpcpp/config |
(added
(done also in wernight/docker-mopidy and wernight/docker-ncmpcpp) However it seems it cannot connect to 5555 even though the log of Mopidy shows it understood the I did however find |
My comment was based off the ncmpcpp source. Mopidy's Mute output is disabled by default i.e. the audio is not muted. The ncmpcpp visualiser will take the output you gave it, disable it (no effect) and then enable it, thus muting the audio. Arguably they should just toggle it twice. The audio being in the wrong format is a good possibility. You have nothing in your gstreamer pipeline to ensure it is correct unlike @adamcik had in his code above. |
Hard to see how the format could be a problem....it's 16-bit signed On 13 May 2015 at 16:33, Nick Steel notifications@github.com wrote:
|
And even if the byte ordering was wrong, you might then just expect the FFT On 13 May 2015 at 16:37, Liam Wickins liamw9534@gmail.com wrote:
|
yeh true, so maybe it's because leaving Mopidy's Mute output enabled means the udpsink won't send any data. |
I looked at visualizer ncmpcpp code:
Anyone can also try from my branch (after having installed Docker):
|
Had to spend quite some time wrangling netcat as -k didn't work for me, but here is what I came up with to autorestart it on song switches:
other options as above basically. |
@S0lll0s @wernight netcat -k also didn't work for me and had to be restarted after song changes. While your solution works, I've found socat to work better:
|
For arch linux users: To get |
@johnhamelink (I presume you are running Arch from your comment) Have you had issues with the visualizer trying to "catch up" after you pause a song using the |
@theos-space I can't say I've noticed that myself |
I'm on Arch and couldn't get it to work with either |
Can confirm this works on debian buster (4.11.6-1), mopidy 2.1.0-1, gstreamer1.0-tools 1.12.2-1, ncmpcpp 0.7.4-1+b3, socat 1.7.3.2-1: start socat in the system startup:
mopidy [audio] conf (note host had to be defined for udpsink):
|
ranisalt for Arch you have to compile ncmpcpp with fifo support check here: https://bbs.archlinux.org/viewtopic.php?id=99915 |
Here's my working Arch setup, after reading the rest of the thread + docs + manpages + assorted blogs. I'm running Mopidy as a system service and sending the audio to the user service PulseAudio via TCP. I've included some additional annotations that will hopefully help the less experienced. PackagesAll of these are from the official Arch repos:
SetupEnable mopidy system service:
Replace mopidy's system config with a symlink to the user config for ease of editing (optional):
Create the fifo file:
Configsin
in
in
in
What this does:
|
Im running mopidy on Manjaro (arch distro). I was having trouble with getting any output through socat or netcat. I was able to observer the packets coming in with tcpdump though: It took me a long while and I wouldn't have found the issue without @mosbasik .
or
On a side note: I wasn't able to get Output of `mopidy deps`
|
I'm running into an issue trying to get udpsink working with Mopidy and all remote ncmpcpp clients. Mopidy is setup with MacVLAN in a docker environment. I can successfully see the port on the container.
Currently Mopidy is using the following bit of config:
Any thoughts to how I can use netcat to successfully get the raw data into mpd.fifo? Using the following doesn't work, I think because I'm using netcat in the wrong way. Some research hasn't provided any answers, so hopefully someone can point me in the right direction.
I get the following error:
Any thoughts on how I can get this to work? Cheers! |
FYI I added support for gstreamer's See ncmpcpp/ncmpcpp@fb886f6 for more details. Below a teaser. This is mopidy + mopidy-spotify + mopidy-mpd + ncmpcpp. simplescreenrecorder-2020-12-17_23.07.55.mp4 |
@arybczak Awesome! You should post this to https://discourse.mopidy.com/c/show-and-tell/9 |
@adamcik Doesn't this mean that this nearly 7-yo issue is "deprecated" in favour of a better resolution to the real-world issue that sparked it (supporting visualisations in ncmpcpp)? |
@pspeder, what exactly do you mean? Is there a problem with using #775 (comment) ? |
@kingosticks Was simply suggesting that this issue be closed 🙂 |
I do agree with that. |
This keeps coming up as people really seem to like ncmpcpp's visualizer
Trick for making a reliable FIFO sink is twofold. You need to use non-blocking writes, which means opening the write socket will fail unless there is a reader, hence you need a reader as well. Secondly if the buffer fills up because the external reader falls behind or there is none, your internal reader needs to clear the buffer.
Following code captures the basic gist of this, but still needs some more work with respect to error handling.
The code above now needs to be integrated with GStreamer do actually do it's thing. Assuming 0.10 this is actually very much doable, reason I am hesitant is that we are planing a move to 1.x and the gir binding are not suited for making elements in python. In the case of this code in 1.x the problem boils down to not being able to create the pad templates that BaseSink expect to find. Creating this as a plain element might be doable, but you would need to re-implement way to much of the handling BaseSink makes sure you get right.
Note that one problem I ran into testing this was actually forgetting to match the audio format expected by ncmpcpp, so make sure mono/stereo do indeed match up.
The text was updated successfully, but these errors were encountered: