Home » Nodejs » Using Node.js to stream audio to html5 audio tag and bypass iOS limitation

Using Node.js to stream audio to html5 audio tag and bypass iOS limitation

Posted by: admin January 30, 2018 Leave a comment


I’m currently working on a project that use HTML5 audio and we have problems with the limitations on iOS devices (mostly multiple audio channels limitation).

I was thinking that it may be possible to control the sounds server-side using node.js. The client would connect to a single audio url and the node server will stream live sounds trough this single channel doing all the mixing and transitions live on the server.

Is it technically possible? Can you parse audio on node.js and do some live mixing? Do you think the server will explode with more than 5 simultaneous clients?



Yes, this is entirely possible, but as Sam pointed out, buffering is an issue. There is significant delay that builds up over several points:

  • Getting control commands from client
  • Mixing raw PCM audio into an internal buffer
  • Encoding data with the correct codec (requires you to do this in chunks)
  • Sending audio data
  • Buffering client-side
  • Playback buffer on client-side

Add this all up, and even if you get it working very quickly, you’re still looking at a couple seconds delay.

If you do decide to go this route, you’ll need an external application (or write your own Node extension) to do the mixing and encoding for you. Sox is probably a decent choice, and FFMPEG includes many codecs for your use. You can use both over STDIO.

Regarding server load… this is not a light-weight kind of process, but you would have to profile it to see how bad it really is. I suggest you make other attempts at playing multiple audio streams at once client-side before attempting something like this.


Please refer to this link. it works as expected but the issue is client control
NodeJS Streaming for Audio/Video with Client Side Control