RTMP server for node
Just add the Medooze media server as a dependency to your node proyect:
npm i --save rtmp-media-server
const brige = RTMPServer.createIncomingStreamBridge();
const demo = RTMPServer.createApplication();
const rtmp = RTMPServer.createServer();
rtmp.addApplication("demo",demo);
rtmp.start(1935);
demo.on("connect",(client)=>{
console.log("connected on "+client.getAppName());
client.on("stream",(stream)=>{
console.log("got stream ",stream.getId());
stream.on("cmd",(cmd,...params)=>{
console.log("got cmd "+cmd.name,params);
if (cmd.name=="publish")
{
try {
//Start publishing
stream.attachTo(brige);
///Started
stream.sendStatus(RTMPServer.NetStream.Publish.Start);
} catch (e) {
//Log it
console.error(e);
//Errror
stream.sendStatus(RTMPServer.NetStream.Failed,e.toString());
}
}
});
stream.on("stopped",()=>{
console.log("stream stopped");
});
});
client.accept();
});
Sergio Garcia Murillo @ Medooze
To get started, Sign the Contributor License Agreement.
MIT