websocket - Web Audio API and livestream delay -


i've been developing audio conference application web audio api , node.js. 1 person speak , other clients connected should hear him.

on client-side i'm encoding pcm samples libopus before sending them server.

on server-side i'm sending encoded packets users connected, , on each client i'm decoding packets samples can played web audio api.

when i'm testing application on local environment working fine. on production environment, when clients can connect outside local space, couple major problems occur.

  1. some clients have delay in audio seems increasing. example, if stream has been going on 1min delay clients can big 10 seconds, , after couple of minutes delay clients bigger 30-50 seconds.

  2. some clients have no problems.

  3. especially clients experiencing delay, sound extremely low-pitched. can happen clients have no delay in audio aswell.

thats because can have different sample rates different sound cards. in case audio heigh-pitched , lag (from pc1->pc2), , low-pitched , delayed time going on (from pc2->pc1). in case pc1's sample rate lower pc2.

you have write resampler solve this. check sample rates on different pcs:

var audioctx = new audiocontext(); var mysamplerate = audioctx.samplerate; 

check post none webrtc solution: can stream microphone audio client client using nodejs?

can give me link opus lib used ? maybe i'll itegrate in project well.


Comments