Quick & Easy: Nginx with RTMP & DASH Streaming Support

Create your own vps streaming server :)

Sample 1080p60 AVC@10Mbps AAC@192kbps

VPS (or use your own)

  • Go to digitalocean.com
  • Create a account
  • Select Size 512MB
  • Select Region closest to you
  • Select Image ubuntu 16.10 x64

Install nginx with rtmp

  • wget https://awesome.nwgat.ninja/nginx-rtmp/nginx-common_1.10.1-0ubuntu1.2_all.deb
  • wget https://awesome.nwgat.ninja/nginx-rtmp/nginx-full_1.10.1-0ubuntu1.2_amd64.deb
  • dpkg -i nginx-full_1.10.1-0ubuntu1.2_amd64.deb nginx-common_1.10.1-0ubuntu1.2_all.deb
  • apt-get install -f

or you can follow Building Nginx with rtmp support

Setting up

  • ufw allow 1935 (rtmp)
  • ufw allow 80 (dash)
  • wget https://awesome.nwgat.ninja/nginx-rtmp/rtmp.conf && cat rtmp.conf >> /etc/nginx/nginx.conf
  • wget https://awesome.nwgat.ninja/nginx-rtmp/dash.conf -O /etc/nginx/sites-enabled/dash.conf
  • rm -rf /etc/nginx/sites-enabled/default (interferes with our configs so backup if you need it

Setup Dash.js

  • cd /var/www && git clone https://github.com/arut/dash.js.git
  • cd dash.js && git checkout live
  • nano baseline.html
  • replace http://dash.edgesuite.net/envivio/dashpr/clear/Manifest.mpd with http://vpsip/dash/live.mpd
  • systemctl restart nginx && systemctl status nginx

Streaming (AMD ReLive)

there is no password or restrictions so you need to add ip whitelisting or user/password
https://helping-squad.com/nginx-rtmp-secure-your-nginx-server/

Crimson Settings > ReLive > Streaming > Custom Stream
Server URL: rtmp://vpsip:1935/live/
Connection Key: live
Streaming Profile: Custom (1080p60 @ 10Mbps/192kbps)

Notes:

  • The quality varies by scenes/games
  • AMD seems to be doing CABAC coding with 2-Pass which is nice
  • no HEVC streaming (yet) even with a custom server
  • rant: why only 10mbps max?????
  • with custom servers you can have a master stream at 25mbps and then transcode it lower on the server side

Streaming (OBS Studio)

there is no password or restrictions so you need to add ip whitelisting or user/password
https://helping-squad.com/nginx-rtmp-secure-your-nginx-server/

  • Settings > Stream > Custom Streaming Server
  • URL rtmp://vpsip:1935/live/
  • Key is live

Watching

  • you can now play rtmp://vpsip:1935/live/live in your player
  • mpv rtmp://vpsip:1935/live/live
  • vlc rtmp://vpsip:1935/live/live

or watch it on the web http://vpsip/dash.js/baseline.html

Save Stream

  • ffmpeg -i rtmp://vpsip:1935/live/live -vcodec copy -acodec copy live.mp4

Sources: