Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to play linux default audio output on Sonos speakers (with delay using http mp3 or flac streaming)

how tu setup pulseaudio->streaming via cvlc (command line vlc -> so should simmilarily work with gui version (in my case don't)):

get pulseaudio source from list:

pactl list | grep "Monitor Source"

and assign to P , e.g. in my case it's usually:


Then run one of following cvlc:


cvlc -vvv "$P" --sout '#transcode{vcodec=none,acodec=flac,ab=1441,channels=2,samplerate=44100,scodec=none}:standard{access=http,dst=}'

or mp3:

cvlc -vvv "$P" --sout '#transcode{acodec=mp3,ab=128,channels=2}:standard{access=http,dst=}'

Now let's use to insert our new (or on playlist! (you may use other tool for that, maybe some other sonos controller will allow you to provide url)

Now , modifying my script to play flac files from flocal serwer ( )

argv[1] = speaker ip (you can get with socos list) assuming you used flac cvlc command, otherwise change line to s.add_uri_to_queue(''):

#!/usr/bin/env python3
import sys
import soco

print('Playing on Speaker with ip='+ip)
print(' get_speaker_info()='+str(s.get_speaker_info()))


When nothing feeds input, then stream gets stuck and sonos speakers give up -> very annying when I try to move video to particular point as it creates short breaks in audio stream then whole setup does not hangle smoothly. Forutnatelly there is solution! Play in background silence in a loop (command to play in a loop from command line taken from ):

ffplay -nodisp -autoexit -loop 9999 silence_10s.wav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.