rsegecin / WLStream

Stream audio from a Windows output device to be captured on a Linux host.
MIT License
53 stars 9 forks source link

High Latency #2

Closed kcappieg closed 7 years ago

kcappieg commented 7 years ago

Hey, stumbled on this solution after days of trying to figure out an effective way to stream Audio (and video) from Windows to Linux...for free.

I tried it out and it does in fact work!

However, there's really high latency, like around 5 seconds.

Any suggestions for reducing latency?

Either way, thanks for putting this out there!

rsegecin commented 7 years ago

I know it was the only bummer when I got it working. As I was broadcasting to my orange pi hooked on my sound system and listening Spotify on Windows it didn't bother so much and I didn't research a way to make it faster. I'm not sure if it's possible to lower the signal latency. My first attempt would be connecting both Windows and Linux systems through a wired network or increase somehow the band-width between them to see if there's any effect. Try to find a program other than linco that can potentially work better piping the data wave, I think it uses TCP and probably it'd work better with UDP. Try something different than pacat. Other than that I don't think there's a better way capturing audio of an output device like WLStream does. Matthew van Eerde would know better. At last programmatically speaking I think if you could set a smaller number of frames than IAudioCaptureClient provides you would be able to increase the number of packets sent to the output and start to broadcast sooner but unfortunately there's no option to set the number of audio frames to be read.

I'm glad to help and if you find a better way to stream the audio please let me know here in the comments.

kcappieg commented 7 years ago

Update: I checked out the man page of pacat: https://sarata.com/manpages/pacat.1.html

Specifically this section:

--latency=BYTES

Explicitly configure the latency, with a time specified in bytes in the selected sample format. If left out the server will pick the latency, usually relatively high for power saving reasons. Use either this option or --latency-msec, but not both.

--latency-msec=MSEC

Explicitly configure the latency, with a time specified in milliseconds. If left out the server will pick the latency, usually relatively high for power saving reasons. Use either this option or --latency, but not both.

The default is high latency, but you can reset it down. I set it to 1ms and it worked perfectly!

As it says in the man page, low latency will strain your system, but my machine can take it. (Definitely haven't stress tested, so I have no idea what the threshold is.)

Thanks again for putting this out there!

rsegecin commented 7 years ago

Such an easy fix, thank you for sharing too! =)