[GH-ISSUE #155] Output to pipe? #95

Closed
opened 2026-02-28 14:25:18 +03:00 by kerem · 14 comments
Owner

Originally created by @praul on GitHub (Dec 29, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/155

Hi there and thanks for your work.
I have been using librespot-java for quite a long time now. With development discontinued I would like to switch to this build.

However, I need the possibility to output audio to a pipe file, since I am using this in a stack with snapserver.

Am I missing a configuration option? Would this be possible to implement? I'd rather not go the route of configuring fake-audio-devices rather than having it implemented direct into go-librespot.

Thanks for consideration

Originally created by @praul on GitHub (Dec 29, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/155 Hi there and thanks for your work. I have been using librespot-java for quite a long time now. With development discontinued I would like to switch to this build. However, I need the possibility to output audio to a pipe file, since I am using this in a stack with snapserver. Am I missing a configuration option? Would this be possible to implement? I'd rather not go the route of configuring fake-audio-devices rather than having it implemented direct into go-librespot. Thanks for consideration
kerem 2026-02-28 14:25:18 +03:00
Author
Owner

@devgianlu commented on GitHub (Dec 29, 2024):

That was missing indeed, but should be implemented now!

I have tested it by creating a pipe with mkfifo /tmp/spotify.fifo and using ffmpeg to play:

ffplay -f f32le -ar 44100 -ch_layout stereo pipe: < /tmp/spotify.fifo

For go-librespot use the following configuration:

audio_backend: pipe
audio_output_pipe: /tmp/spotify.fifo

Let me know if this works for you!

<!-- gh-comment-id:2564720272 --> @devgianlu commented on GitHub (Dec 29, 2024): That was missing indeed, but should be implemented now! I have tested it by creating a pipe with `mkfifo /tmp/spotify.fifo` and using ffmpeg to play: ```shell ffplay -f f32le -ar 44100 -ch_layout stereo pipe: < /tmp/spotify.fifo ``` For go-librespot use the following configuration: ```yaml audio_backend: pipe audio_output_pipe: /tmp/spotify.fifo ``` Let me know if this works for you!
Author
Owner

@joussy commented on GitHub (Dec 30, 2024):

Hi ! Pipe output works fine using ffplay, except there is a delay when pausing. Maybe the buffer isn't flushed when it's paused ?

<!-- gh-comment-id:2565482938 --> @joussy commented on GitHub (Dec 30, 2024): Hi ! Pipe output works fine using ffplay, except there is a delay when pausing. Maybe the buffer isn't flushed when it's paused ?
Author
Owner

@praul commented on GitHub (Dec 30, 2024):

That was fast. Unfortunately it is not working for me (as a drop in replacement). Sound from the pipe (over snapserver, https://github.com/badaix/snapcast) is only distortion.
I cannot test directly on server since it has no audio connected to it.

Is go-librespot somehow using other codec/samplerate than librespot-java?
The only way I can configure snapserver is like 44100:16:2 and its expecting raw pcm..

Maybe you have an idea?

<!-- gh-comment-id:2565486590 --> @praul commented on GitHub (Dec 30, 2024): That was fast. Unfortunately it is not working for me (as a drop in replacement). Sound from the pipe (over snapserver, https://github.com/badaix/snapcast) is only distortion. I cannot test directly on server since it has no audio connected to it. Is go-librespot somehow using other codec/samplerate than librespot-java? The only way I can configure snapserver is like 44100:16:2 and its expecting raw pcm.. Maybe you have an idea?
Author
Owner

@devgianlu commented on GitHub (Dec 30, 2024):

Hi ! Pipe output works fine using ffplay, except there is a delay when pausing. Maybe the buffer isn't flushed when it's paused ?

I think the delay is caused by ffmpeg having an internal buffer that cannot be flushed. go-librespot stops writing to pipe immediately after pause is pressed.

Is go-librespot somehow using other codec/samplerate than librespot-java?
The only way I can configure snapserver is like 44100:16:2 and its expecting raw pcm..

I did not remember that librespot-java used 16-bit signed int, go-librespot uses 32-bit float so that surely is a problem. Are you able to reconfigure snapserver?

<!-- gh-comment-id:2565592899 --> @devgianlu commented on GitHub (Dec 30, 2024): > Hi ! Pipe output works fine using ffplay, except there is a delay when pausing. Maybe the buffer isn't flushed when it's paused ? I think the delay is caused by ffmpeg having an internal buffer that cannot be flushed. go-librespot stops writing to pipe immediately after pause is pressed. > Is go-librespot somehow using other codec/samplerate than librespot-java? > The only way I can configure snapserver is like 44100:16:2 and its expecting raw pcm.. I did not remember that librespot-java used 16-bit signed int, go-librespot uses 32-bit float so that surely is a problem. Are you able to reconfigure snapserver?
Author
Owner

@praul commented on GitHub (Dec 30, 2024):

Unfortunately I don't think so. I can set it to 32bit, but as far as I can tell, snapcast does not support float pcm audio.
Is there a way for go-librespot to output 16bit signed int pcm? I think it would be the most compatible format.

Snapcast Docs states:
The PCM samples (bit depth) must be encoded signed, little endian in 8, 16, 24, or 32 bit, where 24 is expected to be encoded in the lower three bytes of a 32 bit word.

librespot-org offers format feature, but your builds were always more stable, and I am actively using the api, so if its possible, would be much appreciated

<!-- gh-comment-id:2565653944 --> @praul commented on GitHub (Dec 30, 2024): Unfortunately I don't think so. I can set it to 32bit, but as far as I can tell, snapcast does not support float pcm audio. Is there a way for go-librespot to output 16bit signed int pcm? I think it would be the most compatible format. Snapcast Docs states: `The PCM samples (bit depth) must be encoded signed, little endian in 8, 16, 24, or 32 bit, where 24 is expected to be encoded in the lower three bytes of a 32 bit word.` librespot-org offers format feature, but your builds were always more stable, and I am actively using the api, so if its possible, would be much appreciated
Author
Owner

@devgianlu commented on GitHub (Dec 31, 2024):

I have added the audio_output_pipe_format option. Tested with s16le and ffplay -f s16le -ar 44100 -ch_layout stereo pipe: < /tmp/spotify.fifo.

<!-- gh-comment-id:2566450379 --> @devgianlu commented on GitHub (Dec 31, 2024): I have added the `audio_output_pipe_format` option. Tested with `s16le` and `ffplay -f s16le -ar 44100 -ch_layout stereo pipe: < /tmp/spotify.fifo`.
Author
Owner

@praul commented on GitHub (Jan 1, 2025):

It's working great now (and it's so fast). Big thanks, really great support

<!-- gh-comment-id:2566990478 --> @praul commented on GitHub (Jan 1, 2025): It's working great now (and it's so fast). Big thanks, really great support
Author
Owner

@iVolt1 commented on GitHub (Jan 1, 2025):

Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement?

<!-- gh-comment-id:2567165363 --> @iVolt1 commented on GitHub (Jan 1, 2025): Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement?
Author
Owner

@devgianlu commented on GitHub (Jan 2, 2025):

Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement?

@iVolt1 Why not! Please open a separate issue to track this.

<!-- gh-comment-id:2567631214 --> @devgianlu commented on GitHub (Jan 2, 2025): > Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement? @iVolt1 Why not! Please open a separate issue to track this.
Author
Owner

@eoware commented on GitHub (Jan 11, 2025):

It's working great now (and it's so fast). Big thanks, really great support

@praul -- I am thinking of moving from the original librespot to this library for snapserver, could you share your snapserver cli command to start librespot-go? Are you using events? Do you have multiple instances running?

<!-- gh-comment-id:2585345805 --> @eoware commented on GitHub (Jan 11, 2025): > It's working great now (and it's so fast). Big thanks, really great support @praul -- I am thinking of moving from the original librespot to this library for snapserver, could you share your snapserver cli command to start librespot-go? Are you using events? Do you have multiple instances running?
Author
Owner

@FrancisHGR commented on GitHub (Jan 14, 2025):

Hey guys, amazing project. However with mkfifo and the configuration in the config.yml as described above, I get the following error:

WARN[0006] failed handling dealer request error="failed loading current track (transfer): failed setting stream for spotify:track:56hg2LjYQ9RFp5ffnUPetE: unknown audio backend: pipe"

Any help?

<!-- gh-comment-id:2591311065 --> @FrancisHGR commented on GitHub (Jan 14, 2025): Hey guys, amazing project. However with mkfifo and the configuration in the config.yml as described above, I get the following error: WARN[0006] failed handling dealer request error="failed loading current track (transfer): failed setting stream for spotify:track:56hg2LjYQ9RFp5ffnUPetE: unknown audio backend: pipe" Any help?
Author
Owner

@FrancisHGR commented on GitHub (Jan 15, 2025):

Okay I think I got it, v0.1.3 hasn't included the pipe to audio backend feature...

built it now from source and is running. However unfortunately I can connect to the the go-librespot spotify connect device, but when I press play on the phone the connection disappears and go-librespot spotify connect is not reachable anymore. It seems to be unstable.

<!-- gh-comment-id:2591371055 --> @FrancisHGR commented on GitHub (Jan 15, 2025): Okay I think I got it, v0.1.3 hasn't included the pipe to audio backend feature... built it now from source and is running. However unfortunately I can connect to the the go-librespot spotify connect device, but when I press play on the phone the connection disappears and go-librespot spotify connect is not reachable anymore. It seems to be unstable.
Author
Owner

@devgianlu commented on GitHub (Jan 15, 2025):

However unfortunately I can connect to the the go-librespot spotify connect device, but when I press play on the phone the connection disappears and go-librespot spotify connect is not reachable anymore. It seems to be unstable.

Please open a separate issue including the logs

<!-- gh-comment-id:2593385854 --> @devgianlu commented on GitHub (Jan 15, 2025): > However unfortunately I can connect to the the go-librespot spotify connect device, but when I press play on the phone the connection disappears and go-librespot spotify connect is not reachable anymore. It seems to be unstable. Please open a separate issue including the logs
Author
Owner

@jangerhard commented on GitHub (Aug 27, 2025):

Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement?

@iVolt1 Why not! Please open a separate issue to track this.

https://github.com/devgianlu/go-librespot/issues/157

Any progress on this?

<!-- gh-comment-id:3229473737 --> @jangerhard commented on GitHub (Aug 27, 2025): > > Hi. Will metadata be output to a pipe as it is in librespot-java in a future enhancement? > > [@iVolt1](https://github.com/iVolt1) Why not! Please open a separate issue to track this. https://github.com/devgianlu/go-librespot/issues/157 Any progress on this?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#95
No description provided.