Skip to content

Instantly share code, notes, and snippets.

@Fusl
Last active June 30, 2024 17:48
Show Gist options
  • Save Fusl/3a708b8c32c9d5264fa0 to your computer and use it in GitHub Desktop.
Save Fusl/3a708b8c32c9d5264fa0 to your computer and use it in GitHub Desktop.
Streaming audio output from Linux (Pulseaudio) to Windows
# Windows (receiver) side:
.\ffplay.exe -nodisp -ac 2 -acodec pcm_u8 -ar 48000 -analyzeduration 0 -probesize 32 -f u8 -i udp://0.0.0.0:18181?listen=1
# Linux (transmitter) side:
pactl load-module module-null-sink sink_name=remote
ffmpeg -f pulse -i "remote.monitor" -ac 2 -acodec pcm_u8 -ar 48000 -f u8 "udp://RECEIVER:18181"
pavucontrol # Change the default output to the Null sink or move single applications to this "output" device.
@gmeks
Copy link

gmeks commented Aug 25, 2022

Nope

@PatienceAllergy
Copy link

so did anyone find a fix for latency? (1 sec on Linux Lite -> win 11)

Yes. I haven't used Windows for over a year, so this was with Windows 10. It involved ditching ffmpeg piping, and using an old version of PulseAudio that was ported to Windows ages ago. Once both systems (Linux, Windows, or whatever) are using PulseAudio as a platform for sound, then you can network the PulseAudio way, which is very low latency. You can watch movies over the network with no noticeable delay.

Here is the post that got me started. I can't remember if I used version 1.1 or 5 that they mention.

https://www.reddit.com/r/bashonubuntuonwindows/comments/hrn1lz/wsl_sound_through_pulseaudio_solved/

Couple of things:

  • make sure the user on both machines have the same cookie file (often here on Linux ~/.config/pulse/cookie), so copy this over to where your PulseAudio config is on Windows. On Windows it didn't seem to store anything in your home folder, everything was just in the one folder.
  • on the receiving machine put this in the equivalent of /etc/pulse/client.pa: default-server = 192.168.7.3
  • on the transmitting machine put this in the equivalent of /etc/pulse/default.pa:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;<insert IPs of machines>

The IPs would be listed like 192.168.0.1;192.168.0.2 or CIDR notation like 192.168.0.0/24 to specify a range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment