airsonos icon indicating copy to clipboard operation
airsonos copied to clipboard

Synchronized Sound Output

Open ghost opened this issue 11 years ago • 26 comments
trafficstars

When I stream a movie or just when I hit next song on Spotify there's a delay of 0.5s I can't watch a movie when the sound is not sync correctly.

My sonos play5 is connected by ethernet and the laptop is on the Wifi.

I think we can fix this by starting the playback at 0:05s ahead instead of 0:00. Any ideas?

ghost avatar Oct 19 '14 13:10 ghost

I've also experienced this, but this seems to be isolated to streaming audio from my mac. when i stream from an ios device there is no lag / delay. Is there any way to fix this?

fordjam avatar Feb 13 '15 21:02 fordjam

It comes from the Airplay standard, no ?

picsoung avatar Mar 07 '15 14:03 picsoung

Anyone working on solving this issue, or is it actually the video that needs to be delayed, because the sonos is that much slower?

sp90 avatar Jun 01 '15 12:06 sp90

Can confirm, on ipad ios 7.1.2. Interestingly, plex and direct safari video playback are affected, but youtube is not.

odcinek avatar Jun 02 '15 03:06 odcinek

@stephen could you provide some context on this? After cursory look at teh code it looks more like a https://github.com/stephen/nodetunes issue

odcinek avatar Jun 02 '15 03:06 odcinek

Hi all

I am experiencing the same issue when streaming from my iMac. Any fix I can implement in order to have video and sound synchronized?

Other than that, thanks for the Airsonos development, it's great.

jiji2x avatar Aug 17 '15 16:08 jiji2x

I also agree that the video should be slightly delayed. Syncing that is probably difficult since airsonos can't control specific applications like VLC. You can delay the video of VLC quite easilly yourself with the the F and G keys.

peteruithoven avatar Sep 18 '15 18:09 peteruithoven

This issue is due to https://github.com/stephen/nodetunes/issues/40

I believe the issue comes down to one or more of the following:

  1. nodetunes not parsing the rtptime from RTP-Info header
  2. The RTP sequence number
  3. timing packets (I don't believe nodetunes handles this)
  4. sync packets (I don't believe nodetunes handles this either)
  5. Incorrect parsing of the RECORD request (it includes initial RTP sequence number and initial RTP timestamp)

I don't understand the AirPlay protocol well enough and have only been looking into the matter for less than 2 days.

More info Sync Packets:

Sync packets are sent once per second to the control port. They are used to correlate the RTP timestamps currently used in the audio stream to the NTP time used for clock synchronization.

Timing Packets: Timing packets are used to synchronize a master clock for audio. This is useful for clock recovery and precise synchronization of several devices playing the same audio stream.

bugs181 avatar Jan 07 '16 06:01 bugs181

i have the same issue. when i play a video on my iphone, the sound starts a few seconds later. there's no sync. if there was a solution to this, then this would seriously be the best app ever.

jonbid avatar Apr 09 '16 18:04 jonbid

ok, so I've been playing around with this. it seems the delay is 4.7 seconds. so using video playback apps on iOS that let you adjust the delay makes things work perfectly.

I am using VLC for iOS to playback files that use DTS codec (movies... this is one of the only apps that supports this codec) and AVplayerHD for everything else. then I adjust the audio delay in each app to -4.7 and the audio and video is now in sync.

only issue now is playing videos from a web browser/YouTube.

jonbid avatar Apr 14 '16 19:04 jonbid

Question regarding audio sync/delay:

For a long time, using AirSonos on a clean RPi2 - using a iOS6-iPad (YouTube App Video Playback) has been almost in sync. You could watch the video on the iPad and the sound send via AirPlay to the Sonos (Play:1) was only slightly(!) out of sync (talking about 0,5 seconds or so). After not using the setup for some month - today - this is not possible anymore because of the approx 4 seconds delay.

What has changed? Does it have to do with the never Sonos Software Versions? (Nothing else seems to have changed. The AirSonos setup is exactly the same, so is the iPad)

Thanks.

axbmcuser avatar Jul 03 '16 09:07 axbmcuser

it would take the dev doing some work to get things to sync with youtube etc... not sure he cares :/

jonbid avatar Jul 23 '16 01:07 jonbid

I'm fairly certain most of the delay is caused by streaming with shoutcast. The audio needs to be encoded to mp3 server-side before it's streamed, which can take 500~1000ms, then you have the client playback buffer, which can add several seconds depending on the client. @axbmcuser I imagine, all else being the same, that Sonos increased the playback buffer.

knubie avatar Oct 23 '16 22:10 knubie

think there is a workaround?

jonbid avatar Oct 23 '16 22:10 jonbid

apple is now selling Sonos in apple stores, so i think there probably will be airplay support eventually in a new model.

jonbid avatar Oct 23 '16 22:10 jonbid

@jonbid I don't think so. In order to play anything you need to send two requests to the Sonos, one to queue up the song, and another to play it. Together they add up to 200~300ms, which is better, but still not good enough for video.

If there was some way to skip the queue step, it might work, as that was typically <100ms in my tests.

knubie avatar Oct 23 '16 23:10 knubie

Actually, on second thought I guess it doesn't really matter how long it takes to queue it up. I'll keep looking into it.

knubie avatar Oct 23 '16 23:10 knubie

what ive been doing is using VLCplayer to playback videos and then adjusting the audio sync a few seconds slower to get the video/audio in sync... but its kind of irritating having to do that every time. and playing back videos in a web browser is still out of sync. wish there was a simpler solution.

jonbid avatar Oct 24 '16 21:10 jonbid

@jonbid If you're using silverlight to stream video (e.g. netflix) there is a 'hidden' menu you can open to adjust a/v synchronization. But like you said, it's pretty inconvenient.

knubie avatar Oct 24 '16 22:10 knubie

I have been trying to use my Mac connected to speakers via headphone jacks with Sonos in the back of the room as surround speaker, but no luck because of the delay. Any help would be appreciated!

tzm41 avatar Dec 18 '16 05:12 tzm41

Synchronisation seems to be the most wanted feature and at the same time difficult to implement. I will pay EUR 300 to the person who finds a solution and makes it available to everybody here at github. Anybody else willing to contribute money to this project?

stef-germany avatar Jan 26 '17 09:01 stef-germany

@stef-germany You should open a bounty on https://www.bountysource.com/ I would consider contributing, I'm sure others would as well.

knubie avatar Feb 01 '17 22:02 knubie

@knubie I looked at https://www.bountysource.com/. Seems straightforward. One important thing is not clear to me, though: how can one spread the word about the bounty? The whole thing makes little sense if nowbody knows about it.

stef-germany avatar Feb 06 '17 12:02 stef-germany

no way to fix the 4 sec delay yet?

nulloxide avatar May 08 '17 21:05 nulloxide

sonos announced today that airplay is coming to sonos in 2018, so this will no longer be needed.

jonbid avatar Oct 05 '17 03:10 jonbid

Great news!

axbmcuser avatar Oct 05 '17 12:10 axbmcuser