Quick tutorial on how to play sound from your computer to a Sonos device
192.168.1.111 IP of your Sonos Device
192.168.1.128 IP of your computer
Append to /etc/pulse/default.pa:
load-module module-null-sink sink_name=rtp channels=2 rate=44100
load-module module-rtp-send source=rtp.monitor destination=127.0.0.1 port=46998 loop=1
set-default-sink rtp
Restart PulseAudio with pulseaudio -k (if pulseaudio doesn't turn itself on start it with pulseaudio -D)
Select one of these two methods. Try them and see which one performs better
cvlc --live-caching 800 "rtp://@127.0.0.1:46998" --sout "#transcode{vcodec=none,acodec=mp3,ab=256,channels=2,samplerate=44100}:http{dst=:8554/audio.mp3}"
Then play with URI http://192.168.1.122:8554/audio.mp3.
ffmpeg -i 'rtp://127.0.0.1:46998' -q:a 0 -map a -f mp3 pipe:1 | cvlc -vvv - --live-caching 500 --sout '#standard{access=http,mux=mp3,dst=0.0.0.0:8554}'
Then play with URI x-rincon-mp3radio://192.168.1.128:8554/.
sudo iptables -I INPUT -p tcp --dport 8554 -j ACCEPT
.play_uri(URI) argument must be either http://192.168.1.122:8554/audio.mp3 or x-rincon-mp3radio://192.168.1.128:8554/ - depending on which method you chose above.
from soco import SoCo
my_zone = SoCo('192.168.1.111')
my_zone.play_uri('http://192.168.1.128:8554/audio.mp3')
Enjoy 🎵
I found a shorted path. Tested on Debian 6.1.76-1.
Identify the audio interface to stream:
With
cvlcdefine the input interface onpulse://interface_nameand define thestdoutfor mp3 and http.With sonos-cli: