Streaming audio from linux to Windows

Stuff I am working on
Post Reply
Daniel Wee
Site Admin
Posts: 2449
Joined: Wed 25 Feb 25 2009 8:00 pm

Streaming audio from linux to Windows

Post by Daniel Wee »

On Windows' side:
* Using the 16-bit uncompressed stream results is far lower latency than the 8-bit compressed stream
https://gist.github.com/Fusl/3a708b8c32c9d5264fa0
https://wiki.archlinux.org/title/PulseAudio/Examples

1. Download ffmpeg from:-
https://www.gyan.dev/ffmpeg/builds/ffmp ... se-full.7z

2. Extract the bin directory to where you can run ffplay.exe

3. Run command:-

Code: Select all

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
For 16-bit uncompressed stream:-

Code: Select all

ffplay -nodisp -ac 2 -acodec pcm_s16le -ar 48000 -analyzeduration 0 -probesize 32 -f s16le -i udp://0.0.0.0:18181?listen=1
4. Route UDP packets from port 18181 to the localmachine in the router.

On Ubuntu's side:

1. Install ffmpeg:-

Code: Select all

sudo apt install --upgrade ffmpeg
2. Load the sink and loopback module:-

Code: Select all

pactl load-module module-null-sink sink_name=remote
pacmd load-module module-loopback latency_msec=5
3. Stream the data:-

Code: Select all

ffmpeg -f pulse -i "remote.monitor" -ac 2 -acodec pcm_u8 -ar 48000 -f u8 "udp://namly.dyndns.org:18181"
For 16-bit uncompressed stream:-

Code: Select all

ffmpeg -f pulse -i "remote.monitor" -ac 2 -af aresample=async=1 -acodec pcm_s16le -ar 48000 -f s16le "udp://namly.dyndns.org:18181"
-f force format to "pulse"
-i input file is "remote.monitor"
-ac number of audio channels "2" (may want to try 1)
-af aresample=async=1 re-synchronize to avoid non-monotonically increasing data warning
-acodec use code "pcm_s16le"
-ar audio rate 48000Hz
-f force format again to "s16le"
4. Adjust system playback volumes.
Post Reply