0

I am trying to get audio to LedFx, a controller for sound reactive LEDs. One of the ways it can read audio through its docker container is through a named pipe. The command ffmpeg -y -i http://wms-15.streamsrus.com:11630 -f u16le -acodec pcm_s16le -ac 2 -ar 44100 ~/audio/stream is able to play audio into the container, but for some reason, every ffmpeg, parecord, or arecord command that I use to capture system audio doesn't work.

I am on Raspbian Lite, and I've changed my soundcard from the audio jack output to a USB dac output by setting this in /usr/share/alsa/alsa.conf:

defaults.ctl.card 1
defaults.pcm.card 1

I am recieving audio from bluetooth with the rpi-audio-reciever project, and everything is working properly and playing on my DAC. How can I route this audio to my LEDs too?

4
  • Any reason not to use PulseAudio? It comes with a lot of plugins, including network and bluetooth. Commented Mar 11, 2021 at 11:19
  • @DmitryGrigoryev No reason not to. Pulseaudio is installed on the system. I've just solved all the audio receiving problems without it, and LedFx is running inside a docker container. If you can figure out how to route audio into that named pipe with Pulseaudio, that would be great. I've already tried module-pipe-source with no luck.
    – Byte11
    Commented Mar 11, 2021 at 20:53
  • With Pulse you woldn't need the pipe, you could receive your audio directly using pulseaudio-module-bluetooth. Commented Mar 16, 2021 at 10:14
  • Right, but I'm already receiving audio through bluetooth and hearing it play over my speakers. pulseaudio-module-bluetooth accomplishes the same thing rpi-audio-reciever uses bluealsa for. The key is also sending the audio to LedFx
    – Byte11
    Commented Mar 17, 2021 at 18:36

1 Answer 1

1

I cannot add a comment because I don't have reputation 50. This question is 2 years old, but I landed here by searching for the same as you did. You didn't told us by which user you are running ffmpeg command and what is certain error when you try to stream your audio device. Depending on this, there could be few answers. I can tell you that I am on Archlinux desktop PC and I am able to do what you wanted.

As described here, check the names and/or numbers of your audio device. Below is my output:

[stiw47@archmedia ~]$ pactl list short sources
54      VirtualIn.monitor       PipeWire        float32le 2ch 48000Hz   RUNNING
62      TestVirtual.monitor     PipeWire        float32le 2ch 48000Hz   RUNNING
70      VirtualOut      PipeWire        float32le 2ch 48000Hz   IDLE
431     File    PipeWire        float32le 2ch 48000Hz   SUSPENDED
455     alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor        PipeWire        s32le 2ch 48000Hz       RUNNING
1145    VirtualIn.monitor       PipeWire        float32le 2ch 48000Hz   SUSPENDED
1154    VirtualOut_sink.monitor PipeWire        float32le 2ch 48000Hz   SUSPENDED
1161    VirtualOut      PipeWire        float32le 2ch 48000Hz   SUSPENDED

Then, use either number or device name in your ffmpeg command:

ffmpeg -y -f pulse -i 455 -f u16le -acodec pcm_s16le -ac 2 -ar 44100 /home/stiw47/docker-compose-music/ledfx/audio/stream

This working like a charm for my case, and thanks for your ffmpeg command.

TL;DR

First time, my docker-compose-music folder was in /root directory, so i got either:

  • /root/docker-compose-music/ledfx/audio/stream: Permission denied - if I'm running ffmpeg as regular user

OR

  • 455: No such process - if I'm running ffmpeg as root

Since I moved /root/docker-compose-music to /home/stiw47/docker-compose-music, everything is working like a charm, I'm running ffmpeg command as user stiw47

If you update your question, most probably I can give precise answer, but I think this will be also useful for other people.

3
  • I don't remember the details of this question anymore, but I think I went with a different approach. I did succeed though, the code is here: github.com/ShiromMakkad/LedFxDocker
    – Byte11
    Commented Jun 4, 2023 at 3:50
  • Hehe, I'm using exactly the same docker container :) In mean time, I found different way as well. If you have no Pulse installed, or if you cannot compile FFMpeg with pulse enabled (as far as I can see, precompiled FFMpeg binaries for arm64 weren't compiled with pulse), you can use alsa as source format, e.g. in my case: ffmpeg -f alsa -i hw:0,12 -f u16le -acodec copy udp://192.168.0.21:8899
    – stiw47
    Commented Jun 4, 2023 at 11:48
  • 1
    ffmpeg -f alsa -i hw:0,12 -f u16le -acodec copy udp://192.168.0.21:8899 You can determine your device with aplay -l and/or arecord -l. In above example, -i hw:0,12, 0 is sound card, and 12 is device number (subdevice). TL;DR I wanted to send audio via network from my rooted LG TV to my Archlinux home server to LedFx webOS is slightly different Linux (but still Linux). So I uploaded FFMpeg binary for arm64 to TV, and this is working. It is working very well and accurate, but I have latency of about 3 seconds, so most probably will search for another approach (server AUX maybe).
    – stiw47
    Commented Jun 4, 2023 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.