NodeJS and RED 5 media server via RTMP
Asked Answered
L

4

61

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.

  • easy validation of user interaction by running e.g. express and socketIO
  • hybrid implementation of a flash (via RTMP) and getUserMedia() (via binary transport mechanisms by adding binaryJS and the Mozilla AudioAPI)
  • if getUserMedia() gets fully supported, flash implementations can be dropped easily
  • more control over the rtmp followup and user interaction in general
  • easier implementation into server frameworks

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?

Languishing answered 24/10, 2012 at 15:33 Comment(3)
Excellent question. Yes, it is possible. There are a couple RTMP Node.js projects out there. I haven't used any personally, so I cannot provide a good recommendation.Neckerchief
I would recommend you to write a C extension binding for the rtmpDump (rtmpdump.mplayerhq.hu) library, as described here cloudkick.com/blog/2010/aug/23/writing-nodejs-native-extensionsCeaseless
I don't really know anything about node.js, but bigbluebutton implements something like this in flash, and they are working on an html 5 solution. It might be worth checking out the code.Perverted
R
2

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.

Rational answered 13/4, 2013 at 13:31 Comment(3)
+1 on #1 - Red5 is totally undocumented/out of date, and issues opened against it sit for months, yet they keep making releases that don't ever address open issues.Hardesty
Under documented sure, buggy? Try a newer version or pay for a commercial server. Complaining without offering solutions isn't helpful to anyone.Clifford
Red5 is buggy and undocumented, at least it was 2 years ago. But I guess nothing changed, because it's development is too slow. I guess you need to check commersial solutions, one of them are very cheap, around 50$ for a month with a good scalability possibilities (written in erlang, not java).Succotash
I
1

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.

Iconoscope answered 31/12, 2013 at 12:15 Comment(0)
Z
1

WCS is a hybrid implementation for Flash, WebRTC, SIP, Websockets and Wowza compatible protocols: RTSP, RTMP.

Stream conversion scheme: enter image description here

Zosi answered 11/9, 2015 at 21:29 Comment(0)
B
0

this is an old question but, i'm posting this alternative for people who are gonna stumble upon this. Node media server is quite a good media server i have used it in one of my poc it support rtmp https://www.npmjs.com/package/node-media-server

its git repo is also quite lively, In fact i have done some changes before useing it in my poc. And code is also well written. https://github.com/illuspas/Node-Media-Server

PS. its works like a charm with OBS for live streaming.

Belsky answered 18/7, 2018 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.