This is more a conceptual question rather than a direct "how to do this".
Is it generally possible to implement a flash-like solution to stream the audio (independent of where we get the stream data from, e.g. webRTC or other) in HTML5 and nodeJS/binaryJS. If so, how would you go about this?
There has been only one inquire on stackoverflow found here and its from 2010. NodeJS and HTML5 have grown and matured since then.
What people usually do: When using multimedia streaming (i.e. video or audio) to a server, there is definitely nothing that beats Flash at the current point in time till the full arrival of getUserMedia() - which quite honestly might take a while till 99% of the browser users will get to use it at all.
General practice to stream data to the server is by using a client Flash or Flex application which is then connecting to a RTMP protocol powered media server like RED5, FMS or Wowza. For example, the client app sending the microphone input over RTMP could look like (simplified version)
import flash.net.NetStream; private var myMic:Microphone; private var nc:NetConnection; private var ns:NetStream nc = new NetConnection(); ns = new NetStream(nc); nc.connect(rtmp://localhost/serverApp); myMic = Microphone.getMicrophone(); ns.attachAudio(myMic);
Together with a server application one is easibly able to stream data to the server.
What I would like to do: Have an app server running on nodeJS (possibly implementing socketIO and binaryJS) that catches the incoming RTMP stream. Something like
//require var rtmp = require('node-rtmp'), var fs = require('fs'); //rtmp server address var rtmpServer = 'rtmp://localhost'; //create a binary server listening that receives stream data var RTMPServer = rtmp.RTMPServer(); var server = RTMPServer ({port: 1935}); server.on('connection', function(client){ //check if user is allowed to do so rtmp.newStream(client.stream); });
Possibly it might be better to use socketIO to differentiate between user interactions via eventEmitters.
What might be the advantages: Generally speaking it seems like a bit overhead to make this kind of approach, but for me there might be advantages and I'd also like you to comment on this.
UPDATE: I've talked to Mr. Malcontenti-Wilson who is responsible for the only node-rtmp package that was written but discontinued 8 months ago as it was poorly written and he hit a roadblock. Anyone who used this or was able to check the code?
UPDATE 2: Mr. Malcontenti-Wilson just send me a mail to get my attention to node-mtrude (kind of an odd name) which is doing kind of what we would probably want. Has anyone work with this kind of package?
There is now a platform called vertx available where polygot development is possible. So red5 jar can be included on your server side with existing code and could run a rtmp streaming server. At the client side you can have something like video.js or JW player to play the stream back and has got the flash fall back policy. The client side publishing, i am not sure if there are any javascript based RTMP implementation available or not.
Yes it is possible, but you have a few problems.
1) Red5 is terribly under-documented and buggy.
2) rtmpe/rtmps
3) performance/scalability
4) 1 through 3 are things you can overcome, but not without getting to know media distribution and all of it's associated issues very intimately. By the time you're done, you will be one of like 800 people out there who really understand it. You'll have to go down a long path of solving unexpected problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With