philippe44 / LMS-ShairTunes2W

Airtunes with LMS (fork of https://github.com/disaster123/shairport2_plugin)
63 stars 3 forks source link

[Feature Request] Support for "no encoder", leaving the stream as is to ALAC #37

Closed qosmio closed 3 years ago

qosmio commented 3 years ago

Absolutely LOVE this plugin and your other one LMS-to-Raop. I'm using LMS-to-Raop to connect 4 Sonos Ones and 1 RPi4 shairport-sync (feeds into Snapcast (4 RPi Zero W snapclient speakers)). Took a bit of tweaking, but overall playing directly from LMS works, and syncs to all 8 of my speakers.

My issue is when I add Shairtunes2 into the mix. Currently, the sound is delayed up to 10-15 seconds when casting from my iDevice. So far, I think I've narrow it down to the codec option. Choosing wav seems to bring the syncing down, but it's still ends up off.

I wanted to know if it would be possible to have an option to leave the stream as is, in ALAC. I know hardware SB aren't compatible with the codec, but if we're specifically interested in feeding the stream back into LMS-to-Raop, would that help save unnecessary converting? And possibly avoid syncing issues?

I imagine LMS-to-Roap would also need to be updated? Like, if I choose the compress option, ONLY compress to ALAC if the stream isn't already ALAC.

philippe44 commented 3 years ago

The file needs to be re-encoded as it is cut into chunks in a different way. The codec is not adding significant delay anyway. Now, I'm not sure what kind of synchro you have in mind

qosmio commented 3 years ago

Thanks for clearing that up. I wasn't sure exactly the need to convert the stream initially.

As for the synchronization, was just trying to ensure all the speakers are able to play simultaneously without much drifting. For the most part it's working well, just casting from my phone is sporadic. There's a lot of "moving parts" in the mix to make it work how I want. It's a mix of your Groups, LMS-to-ROAP, Shairtunes plugins and Shairport-Sync and Snapcast.

Just to clarify, if I'm not using any SB/Squeezelite players and sticking just with RAOP clients, is there any reason I should choose FLAC over WAV? If everything is going to be local to my Pi (Shairtunes->WAV->RAOP-plugin) is WAV better suited to save on CPU cycles? Sorry if I'm adding confusion, just trying to find the optimal settings for my setup.

philippe44 commented 3 years ago

Thanks for clearing that up. I wasn't sure exactly the need to convert the stream initially.

As for the synchronization, was just trying to ensure all the speakers are able to play simultaneously without much drifting. For the most part it's working well, just casting from my phone is sporadic. There's a lot of "moving parts" in the mix to make it work how I want. It's a mix of your Groups, LMS-to-ROAP, Shairtunes plugins and Shairport-Sync and Snapcast.

Seems complicated. Remember that synchronization with Shairtunes works for players inside an LMS synchro team. You cannot do AirPlay-level sync (using iTunes) between a "airplay-ified" device by Shairtunes and a real airplay device Just to clarify, if I'm not using any SB/Squeezelite players and sticking just with RAOP clients, is there any reason I should choose FLAC over WAV? If everything is going to be local to my Pi (Shairtunes->WAV->RAOP-plugin) is WAV better suited to save on CPU cycles? Sorry if I'm adding confusion, just trying to find the optimal settings for my setup.

You use Shairtunes+AirPlay bridge just to get sync across AirPlay devices? OMG, that's a lot of overhead... Too bad that iOS has disabled the sync feature you have in iTunes. So if this is what you do, yes, set Shairtunes to send WAV, that avoid a flac compression/decompression so that you only have: iOS(alac) => Shairtunes(alac->pcm) => LMS(pcm) => AirPlay Bridge (pcm->alac)

qosmio commented 3 years ago

You cannot do AirPlay-level sync (using iTunes) between a "airplay-ified" device by Shairtunes and a real airplay device.

Yea 😅 that was a hard lesson to learn. I had initially tried using forked-daapd to wrangle all the airplay clients and have shairport-sync feed audio to it from a pipe. But the syncing there was atrocious.

You use Shairtunes+AirPlay bridge just to get sync across AirPlay devices? OMG, that's a lot of overhead...

It is crazy I know... It's my very hacky way of getting AirPlay 2's multi room (Semi)synchronous audio. It's too bad there aren't any open source AP2 solutions yet. I know there's been some proof of concept but a viable implementation hasn't been worked into shairport-sync yet. Out of all the solutions, using your plugins with LMS actually ended up being the best option. In fact, playing straight from LMS without Shairtunes the audio is always in sync across the Sonos, and Snapcast+Shairport speakers. I don't know how, unless I'm not perceptive to the drift.

iOS(alac) => Shairtunes(alac->pcm) => LMS(pcm) => AirPlay Bridge (pcm->alac)

This helps confirm what I was assuming then. I guess this feature request can be closed then. Thanks for the detailed reply!

philippe44 commented 3 years ago

I've not looked in details at AirPlay2, but it seems to be not yet very clear and the benefits of AP2 vs AP1 are virtually nil