lukasjapan / bt-speaker

A simple Bluetooth Speaker Daemon for the Raspberry Pi 3
GNU General Public License v3.0
496 stars 95 forks source link

Bluetooth audio as HTTP stream? #13

Open 8666 opened 7 years ago

8666 commented 7 years ago

I have multiple UPnP players but I miss Bluetooth as an input audio stream. What is the easiest way to not play the audio locally on the Pi but provide it as HTTP stream? Then I can instruct one or multiple players to use that stream as local 'internet' radio

https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples#HTTP_streaming

lukasjapan commented 7 years ago

bt-speaker pipes the audio stream to a command that you can set in the config file. (see readme)

You could try to set that command to vlc.

The point would be to use piped input.

https://wiki.videolan.org/Uncommon_uses/

Also, the audio stream is raw and does not have any headers or whatsoever, so I guess vlc would need info like sample rate and channel count as command arguments.

Maybe this works: https://forum.videolan.org/viewtopic.php?t=44726

All together the command you need might look like this (untested):

vlc --demux=rawaud --rawaud-channels 2 --rawaud-samplerate 44100 --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}' -

Again, this is untested. If things like that don't work out, you might need to find another software that distributes the audio.

8666 commented 7 years ago

This works fine to record the stream play_command = oggenc - -r -o /home/out.ogg then vlc -vvv /home/out.ogg --sout '#standard{access=http,mux=ogg,dst=:8080}' works fine to stream it

Directly, it does not work, audio.py gives some errors for a broken pipe :) I will experiment more in the next days.

davidarkemp commented 6 years ago

I have something kind of working, but it has a lot of moving parts (because aconv is so complex!)

Basically, I have icecast2 setup on the Pi, and then the play_command is:

sox -t raw -r 44100 -L -e signed-integer -b 16 -c 2 - -t wav - | avconv -i pipe: -f mp3 icecast://source:PASSWORD@127.0.0.1:800/bt.mp3 2>/dev/null

Like I said, there's probably a way of getting rid of the sox requirement (-f s16le?) but all I could get was white noise or an error.

Pl1997 commented 6 years ago

Hi,

I want to do the same thing as what @davidarkemp seems to have succeeded in. I tried your command, but it doesn't work. I have Icecast2 running on my pi on port 8000, with default hackme password (for test purpose) for source etc. So I tried to set play_command to sox -t raw -r 44100 -L -e signed-integer -b 16 -c 2 - -t wav - | avconv -i pipe: -f mp3 icecast://hackme@127.0.0.1:8000/bt.mp3 2>/dev/null but it does nothing, bluetooth keeps playing through jack out only. Would you be kind enough to help me getting through this ?

Thank you very much

Pl1997 commented 6 years ago

Rectification : this setup WORKS when the connected device is my Mac computer... When it's an android or iPhone, it just outputs to pi's jack.

Any idea ?