The problem with RTMP servers

  • Author:Robert Whitney
  • Date:2018/01/14
RTMP is a protocol designed for flash. Unfortunately it can only be played by a flash player, or desktop clients such as VLC media player. With the move from flash to HTML 5 players, it is impossible to get an RTMP stream running. I have been able to overcome this hurdle by creating a server which acts as an RTMP server, then converts the stream over to MP4 and serves it via HTTP. This is just a proof of concept, showing that it is possible to do. I plan on completing this project and putting it on github, however I just don't have the time for it right now, so here is a proof-of-concept which can be modified to suite your needs. Before you can run this you will need to be in the directory containing server.js (this is what I named the file). ## Before you can run the server
$ npm install http rtmpdump rtmp-server
$ sudo apt-get install rtmpdump
## server.js
const RtmpServer = require('rtmp-server');
const rtmpServer = new RtmpServer();

rtmpServer.on('error', err => {
  throw err;
rtmpServer.on('client', client => {
  client.on('connect', () => {
  client.on('play', ({ streamName }) => {
    console.log('PLAY', streamName);
  client.on('publish', ({ streamName }) => {
    console.log('PUBLISH', streamName);
  client.on('stop', () => {
    console.log('client disconnected');


var rtmpdump = require('rtmpdump');
var fs = require('fs');
var options = {
  rtmp: 'rtmp://',
  playpath: 'poc',
  v: null // parameter-less command line switches must have null as a value 
var stream = rtmpdump.createStream(options);
stream.on('connected', function(info) {
  // info provides various details about the stream 
  // duration, resolution, codecs, ... 
stream.on('progress', function(kbytes, elapsed, percent) {
  console.log('%s kbytes read, %s secs elapsed, %s%%', kbytes, elapsed, percent);
stream.on('error', function(err) {
  // as usual, unhandled error events will throw 
stream.on('exit', function(err) {

var http = require('http');

//create a server object:
http.createServer(function (req, res) {
  stream.pipe(res); //write a response to the client
}).listen(8080); //the server object listens on port 8080
Once setup you can run and start streaming to the server. To stream fire up OBS and put the following information in: * **Host:** rtmp:// * **Stream Key:** poc Now point VLC or your HTML5 player of choice to and the stream will start to play.
Robert Whitney
I'm a geek, gamer and breaker of things.
Opinions expressed here, even 💩 ones, are my own and do not represent those of my employer or associates.
Referral Links

Using my referral links is the best way to help me pay for my projects and development servers and get something out of it for yourself.

Copyright©2011 - 2018, Robert Whitney; All rights reserved.
Aeon Address: WmtnQAoEJsfbcjyMJLmfW8SJ3j5VCGGjX4k3hHrc4XbhVcz6dxifHs65h2w3y5gq8Qf4D4tgzb6VxEtggSq5hR8s1CzN1cLeK