HydraPlay icon indicating copy to clipboard operation
HydraPlay copied to clipboard

Question: How to implement external fifo streams

Open MrSliff opened this issue 1 year ago • 5 comments

One more question:

Theres a section in the hydra json config file to add extra streams, hence its described to be implemented soon.

Is there a way to add your own fifo streams like from librespot without snapserver.conf getting overwritten at every start of the container?

Anyways, librespot would be a good replacement for the missing spotify function in mopidy, since it provides a remote speaker to which you can connect your spotify app on the phone and it creates a fifo file which can be consumed by snapcast. For my use case i need multiple librespot instances for different ppl in my household.

MrSliff avatar Sep 20 '22 12:09 MrSliff

Yes, i played with that a few month ago. I don't remember exactly how i did that. But i think you can give it a try by doing the following:

  • add the path (location where your fifos live) to volumes in docker-compose.yml llike

./<path to fifos on your host>/:/tmp/additional_streams

  • add fifos to snapcast_server section in hydraplay config like
		"additional_streams": [
			{
				"label": "BLUETOOTH",
				"source_type": "fifo"
			}
		],

I tested it by using a Bluetooth of my Raspberry Pi as a fifo source. You can change the label to whatever you want. The value behind label is what is showing up in the ui. The fifos are enumerated ( first the mopidy fifos,then the additional fifos). Maybe you need to create a fifo called stream_2.fifo in the mounted docker folder on your host.

The generated snapcast config file will then contain the additional fifos:

https://github.com/mariolukas/HydraPlay/blob/45db126f43071a00712afa9fa5cae05c6b2579b8/src/hydraplay/config/templates/snapserver.conf.j2#L85

mariolukas avatar Sep 21 '22 20:09 mariolukas

Thank you very much!

So i got it working, but for librespot fifo streams to play corretly you need to append &sampleformat=44000:16:2 to line 85, otherwise the stream plays too fast:

source = pipe:///tmp/additionalstreams/stream{{ additional_stream_id |int + hydraplay_config.mopidy.instances| int }}.fifo?name={{additional_streams[additional_stream_id].label}}-{{additional_stream_id}}&sampleformat=44000:16:2

I modified my config with mounting the container directory /app/hydraplay/config/templates to the host

MrSliff avatar Sep 25 '22 20:09 MrSliff

Sorry didnt want to close this :(

MrSliff avatar Sep 25 '22 20:09 MrSliff

Thank you very much!

So i got it working, but for librespot fifo streams to play corretly you need to append &sampleformat=44000:16:2 to line 85, otherwise the stream plays too fast:

source = pipe:///tmp/additionalstreams/stream{{ additional_stream_id |int + hydraplay_config.mopidy.instances| int }}.fifo?name={{additional_streams[additional_stream_id].label}}-{{additional_stream_id}}&sampleformat=44000:16:2

I modified my config with mounting the container directory /app/hydraplay/config/templates to the host

Does it work with your improvement?

mariolukas avatar Oct 23 '22 17:10 mariolukas