matbee-eth / chromecast-audio-stream

Stream your Windows PC's audio to the Chromecast
MIT License
954 stars 76 forks source link

Significant Delay in Playback #64

Open foetusmachine opened 7 years ago

foetusmachine commented 7 years ago

Hi,

I've just installed the latest version (downloaded yesterday) on a windows 7 64-bit machine. I'm using chromecast audio.

Cast firmware: 1.20.66189 Country: AU

The sound all works fine and I can't fault anything else except for a significant delay in sound playback. The source software on the windows machine does not seem to matter.

To show this visually, I recorded the the simple task of clicking play button and waiting for the sound to begin. Refer to the attached soundform I recorded and amplified in audacity for clarity. I've added notes to the image so it's clear what's going on. The music player I was using is MusicBee.

You can see there is just over 2.5 second delay between clicking play and the sound beginning.

I've read issues with delay when using multiple chromecasts and i've played with this setting in chromecast without any improvement. The delay setting only gets up to 100ms which is nowhere near the 2.5 second delay i'm experiencing.

Any assistance or guidance on this issue would be appreciated.

Kind Regards...

delay - copy copy

foetusmachine commented 7 years ago

Update on the above.

The lag seems to grow through out the day. Gets up into the minutes of lag.

A windows restart brings it back to ~2.5 seconds.

mcprat commented 7 years ago

This is similar to what happens when you use Foobar2000 with the extension for BubbleUPnP Server. If you just play a song from your library, about 100-500 ms delay, but when you use "Playback Stream Capture" (similar to what this application does), then the delay is about 2-5 seconds. It has to do with how the application gets the sound. In the first way, the file data itself is simply sent to the chromecast, and the server/chromecast decodes it on the spot. In the other way, the computer's sound card decodes it, and then the application records that and reencodes it to be sent over to the Chromecast (or similar). Even if that's not exactly how it works...there is small latencies added everywhere along the way. One way that the app can bring the latency down a little bit is maybe using ASIO or WASAPI instead of DirectSound as an option, but that might only save about 100-200 ms.

In other words, all this latency is internal, has nothing to do with the programming or internet issues.

foetusmachine commented 7 years ago

Thanks for the input. Not sure it helps me just now, but I guess if I/we all keep providing input and feedback on exactly what's going on, it may lead to a solution. Maybe.

Some further feedback:

I tried opening my windows volume mixer to see when the computer thinks sound is being "heard". I used Spotify as the player this time. I can confirm the two applications - Spotify and ffmpeg.exe both think they are "hearing" the music immediately (no apparent lag).

I can also confirm the computer also believes the device - Speakers are "hearing" the music immediately. I assume the device - Speakers in this case means output from the audio card.

This probably all confirms what you've said above, but though i'd share anyway.

foetusmachine commented 7 years ago

Further question

Does it matter that my windows machine does not have a wifi card? It connects to my network via a gigabit ethernet connection to an ac wireless router.

mcprat commented 7 years ago

I would bet that using wifi would also add latency, so the way you have it (if I understand right) is more ideal.

hwalker10 commented 7 years ago

I have this issue as well! Any fix yet?

mcprat commented 7 years ago

Probably not...You say significant, but in this situation (especially with windows) this is a pretty average delay (unless its more than 5 seconds).

Now other than maybe switching to Linux and writing a completely different program, there is probably some things you can try to get the delay back down to a reasonable number without restarting your whole computer. Try each of these things independently and see which one works the best.

Also @acidhax it would maybe help if the program silently disconnected and reconnected with whatever chromecast was last chosen (or any that are available) whenever there is a network interface change. This is similar to a feature that BubbleUPnP Server has right now and I am pretty sure it was implemented for this very reason.