It took me weeks to get a workable solution and in the process I read hundreds of webpages with ideas, instructions and software to download.
Finally I was able to reject 90% of it and come up with a relatively simple solution.
Kodi -> Alsa -> avconv -> ezstream -> Icecast2 -> Sonos
I've only tried this with OSMC v2015.12-4 (Kodi 15.2)
There are two things to do within Kodi:
- Switch the audio output device
- Adjust the video/audio sync (this method has approx. 5,3 sec. delay)
To be able to tap into the audio stream, the simplest thing is to install the loopback sound module under Alsa. Life is too short for PulseAudio…
avconv (aka. ffmpeg) will capture the audio from the Alsa loopback, convert it to mp3 and send it to Ezstream.
Ezstream can take an mp3 file or stream and feed it to Icecast2.
To stream audio you can use Icecast2. It’s highly configurable, can take many sources and exposes a web interface.
Your Sonos system will need to setup to play a local radio station (mp3 over http) from Icecast2.
For all the details, read my blog article with step-by-step instructions here: