Mopidy YouTube Audio stream to Sonos Player

Is there any way to stream YouTube audio from Raspberry Pi to Sonos? I tried YouSonos but it keeps failing after few days of use.

If sonos can play from an icecast stream you could setup Mopidy to output that. There’s an example icecast config in our docs.

Thank you!
What are the steps to route Mopidy output to Icecast? And I have not been able to find documentation on Mopidy docs on how to search and play YouTube on phone browser using Mopidy-YouTube. I have followed all the installation steps but unable to find launch/run steps.

You’ll find the information at https://docs.mopidy.com/en/latest/icecast/

Mopidy does not stream audio to your browser (unless you use icecast).

There are instructions on how to install and run Mopidy at https://docs.mopidy.com/en/latest/. There are installation and configuration instructions for Mopidy-YouTube at https://github.com/natumbri/mopidy-youtube

Trying. How to search/play YouTube on iPhone? I dont see Mopidy-YouTube launch documentation?

Okay, so I tried searching on Mopidy Client using yt: prefix and tried playing YouTube video from the search results. I also confugred output to Icecast2 but I see below error :

pi@raspberrypi-music:~ $ sudo systemctl status mopidy
● mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-09-10 21:59:21 EDT; 43s ago
  Process: 8389 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
  Process: 8390 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
 Main PID: 8391 (mopidy)
    Tasks: 19 (limit: 2065)
   CGroup: /system.slice/mopidy.service
           └─8391 /usr/bin/python3 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Sep 10 21:59:27 raspberrypi-music mopidy[8391]: INFO     [MainThread] mopidy_mpd.actor MPD server running at [::]:6600
Sep 10 21:59:27 raspberrypi-music mopidy[8391]: INFO     [MainThread] mopidy.commands Starting GLib mainloop
Sep 10 21:59:43 raspberrypi-music mopidy[8391]: INFO     [MpdSession-13] mopidy_mpd.session New MPD connection from [fe80::1850:136f:8bfa:a478]:49786
Sep 10 21:59:45 raspberrypi-music mopidy[8391]: INFO     [YouTubeBackend-3] mopidy_youtube youtube LibraryProvider.lookup "youtube:video/Fascinating Santoor By Pandit S
Sep 10 21:59:45 raspberrypi-music mopidy[8391]: INFO     [Thread-15] mopidy_youtube session.get triggered: list_videos
Sep 10 21:59:45 raspberrypi-music mopidy[8391]: INFO     [YouTubeBackend-3] mopidy_youtube youtube PlaybackProvider.translate_uri "youtube:video/Fascinating Santoor By 
Sep 10 21:59:47 raspberrypi-music mopidy[8391]: [youtube] 1JJOAYwov_E: Downloading webpage
Sep 10 21:59:48 raspberrypi-music mopidy[8391]: [youtube] 1JJOAYwov_E: Downloading js player 8c24a503
Sep 10 21:59:50 raspberrypi-music mopidy[8391]: [youtube] 1JJOAYwov_E: Downloading js player 8c24a503
Sep 10 22:00:00 raspberrypi-music mopidy[8391]: ERROR    [MainThread] mopidy.audio.gst GStreamer error: Could not connect to server
lines 1-20/20 (END)

Below is my audio config (the IP address listed is my Pi address which is running mopidy server):

    [audio]
    #mixer = software
    #mixer_volume = 
    #output =  audioresample ! audio/x-raw,rate=48000,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/tmp/snapfifo
    output = lamemp3enc ! shout2send async=false mount=mopidy ip=192.168.68.120 port=8000 password=hackme
    #buffer_time =

I think the real issue is that I am not able to get mount point showing on Icecast. When I see the IP address at port 8000 it shows me icecast page without any mount point or server status. Not sure what step am I missing here. I did change icecast.xml to change hostname to the Ras Pi IP address.

I made some progress. I can get the icecast mounts shown on the Icecast server page. Now when I search Mopidy in source YouTube, it shows list of tracks but when I play tracks, it plays for 4 seconds and restarts and keeps restarting after 4 sec. Is there any configuration that I am missing?

@kingosticks do you have any suggestions. I was able to add mount to Icecast server and also able to hear audio tone. But when I search audio in YouTube source, when I click on play, it plays for 4 seconds and restarts and keeps restarting at 4 seconds. I placed an mp3 file locally on my Pi, when I play that, same thing happens (restarting at 4 seconds). i can hear tone when I play track on Iris webclient (on the laptop audio) as well as the IceCast mount URL. Not sure what I am doing wrong here.

When I do gst-launch command:

 gst-launch-1.0 tee name=t ! queue ! audioresample ! autoaudiosink t. ! queue ! lamemp3enc ! shout2send async=false mount=mopidy ip=192.168.68.120 port=8000 password=asdf1234

All the parameters after gst-launch-1.0 are from mopidy.conf

And i see below message (stuck here). Not sure if there’s any other way of launching gst-launch

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...

Please can you guide me here.