OBS and Nginx for streaming @ home

This article is a compact version of the tutorial from the OBS forum for those who want a local streaming server at home.
You can download Open Broadcaster Software here.

EDIT: After a few misfortunes with jwplayer (constant breaks), I switched to the promising videojs. Post updated accordingly.

First, you’ll need a few libraries, which you can install with [insert favorite Linux package management software]:

libssl-dev
pibpcre++-dev

Then, Nginx needs to be recompiled with a RTMP module maintained by arut:

wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar xf nginx-1.8.0.tar.gz
cd nginx-1.8.0
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
unzip master.zip
./configure --with-http_ssl_module --add-module=./nginx-rtmp-module-master
make
sudo make install

Nginx configuration : /usr/local/nginx/conf/nginx.conf
In the ‘server’ section:

listen 8000; # Or whatever port suits you

Then add a new rtmp section at the end:
  1. rtmp {
  2.         server {
  3.                 listen 1935;
  4.                 chunk_size 4096;
  5.  
  6.                 application live { # Application name, could have been pony or menakedinmaroomlol
  7.                         live on;
  8.                         record off;
  9.                 }
  10.         }
  11. }

Then launch the server:
usr/local/nginx/sbin/nginx

Then, you’ll need a Web player to stream the content. I chose videojs, but any player should do the trick. You’ll of course need a web server to host it somewhere. Apache is fine. SimpleHTTPServer is fine too.

First, get videojs on their website (or on Github if you’d like a self-hosted player)
Then:

unzip video-js-5.10.4.zip
cp -R videojs-5.10.4 /var/www/ # or whatever folder suits you

And create the web page that will host the player:
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <link href=“videojs/video-js.min.css” rel=“stylesheet”>
  6. <script src=“videojs/video.min.js”></script>
  7. <script>
  8.   videojs.options.flash.swf = “videojs/video-js.swf”
  9.   </script>
  10. <video id=“example_video_1” class=“video-js vjs-default-skin vjs-big-play-centered”
  11.        controls preload=“auto” width=“640” height=“360”
  12.        poster=“pony.jpg”
  13.        data-setup=‘{“example_option”:true}’>
  14.   <source src=“rtmp://192.X.X.X/live/test” type=“rtmp/mp4” />
  15.   <p class=“vjs-no-js”>To view this video please enable JavaScript, and consider upgrading to a web browser that <a href=“http://videojs.com/html5-video-support/” target=“_blank”>supports HTML5 video</a></p>
  16.   </video>
  17. </body>
  18. </html>

 

Finally, you’ll just need to configure OBS to stream to your newly deployed nginx:

Streaming Service : Custom
Server : rtmp://192.X.X.X/live
Play Path/Stream Key : test

Profit !

Leave a Reply