Reputation: 85
I've been developing an audio conference application with Web Audio API and Node.js. One person will speak and other clients who are connected should hear him.
On the client-side I'm encoding PCM samples with libopus before sending them into server.
On the server-side I'm just sending those encoded packets back to users who are connected, and finally on each client I'm decoding those packets back to samples that can be played with Web Audio API.
When I'm testing the application on local environment everything is working just fine. On production environment, when the clients can connect from outside local space, couple major problems will occur.
Some clients will have a delay in their audio which seems to be increasing. For example, if the stream has been going on for 1min the delay for some clients can be as big as 10 seconds, and after couple of minutes the delay for some clients is even bigger 30-50 seconds.
Some clients have no problems.
Especially the clients that are experiencing the delay, the sound is extremely low-pitched. This can happen for the clients who have no delay in their audio aswell.
Upvotes: 0
Views: 974
Reputation: 2490
Thats because you can have different sample rates with different sound cards. So in this case the audio is heigh-pitched and lag (From PC1->PC2), and low-pitched and delayed with time going on (From PC2->PC1). In this case PC1's sample rate is lower than PC2.
you have to write a resampler to solve this. Check the sample rates on different PCs:
var audioCtx = new AudioContext();
var mySampleRate = audioCtx.sampleRate;
Check my post about none WebRTC solution: Can I stream microphone audio from client to client using nodejs?
can you give me the link to the Opus Lib you used ? Maybe I'll itegrate this in my project as well.
Upvotes: 1