Need help with audio steams from one qube to another via network
I want to implement a workaround for the issue #10320 of sound of Windows 10 qube being crackling, probably due to 44.1/48kHz broken resampling (it’s a regression of R4.2 compared to R4.1).
To work-around this problem I want to stream all sound from one Windows 10 qube to another Fedora-based and play all sound there as usual.
I want a solution that would provide no sound delays and buffering, just stream sound in any codec and any compression or without compression, and play in Fedora-based qube. Seem to be completely doable.
I almost solved this, but still need help from somebody experienced, especially with “no delays” part.
What I did:
- Created 3 qubes: windows qube, firewall-router qube and fedora based player qube for playing sound, let’s call them:
win→router←fedora
Both win and fedora qubes have network qube (netvm) set to router qube.
- I adjusted firewall rules of qube according to docs:
Enabling networking between two qubes
So, I now have direct IP connection from win to fedora and vice versa. So far so good. Pings go without problems in less than 1 ms, so sound delay should not happen due to network.
Let’s call IPs of these qubes: winIP, routerIP, fedoraIP. Essentially these are 10.137.0.* IPs, of course.
- I installed Virtual sound card in
winqube
I used VB-CABLE Virtual Audio Device, which is donationware/freeware driver from here: VB-Audio Virtual Apps . It has good reputation, so, I am OK with running such proprietary tool (not FLOSS) in Windows qube, as the whole OS and other apps are proprietary there, too.
I set the system sound output card to CABLE Output (VB-Audio Virtual Cable) in win qube.
- I installed
ffmpeginwinqube.
And I can run there:
C:\ffmpeg\bin> ./ffmpeg -f dshow -i audio="CABLE Output (VB-Audio Virtual Cable)" -ac 2 -ar 48000 -c:a pcm_s16le -f s16le -flush_packets 1 "udp://fedoraIP:12345?pkt_size=800&buffer_size=1316"
This command streams all sound from audio card to network address fedoraIP:12345 via UDP (12345 is just port number that I selected randomly).
Alternative way is to run OBS application in win qube and stream audio from it with GUI, but I did not try it yet. Will it be better?
- I have
ffmpeginfedoraqube, too.
I run ffmpeg there to play the receiving stream (via ffplay in my case):
ffmpeg -f s16le -ar 44100 -ac 2 -i udp://0.0.0.0:12345 -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 0 -max_delay 0 -reorder_queue_size 0 -f wav - | ffplay -nodisp -autoexit -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 0 -
And it WORKS! Kind of.
The audio is played without clacking nor noises, finally. But the problem is the starting delay, which is like unacceptable, like 5 seconds. So, when I open video player in win qube and start playing, in 3-5 seconds I get sound that comes to dom0 (default audio qube) from fedora qube.
The sound is fine, but when I move the playing position in player, I still have to way 3-5 seconds lag for sound to be changed. Completely non-functional for my case. If one plays something like a game, the sound being delayed by 5 seconds is not acceptable.
Any ideas or experience how to make the playback change fast and instant?
I thing something like buffering should be reduced, but I am not sure how to do that.
Or maybe the problem is the chosen virtual sound card? Or maybe stream codec or something else?