_______ ____ ____ __ __ ____ __ ______ ______ /_ __// __// __// /_/ // _ / / / / __ // ____/ / / / __// /_ / __ // _ < / /_ / /_/ // /_ / /_/ /___//___//_/ /_//____//___//_____//_____/ techblog.koponen.se [ / ] [ howto ] [ reviews ] [ webapps ] [ youtube ] [ links ] [ about ] -------------------------------------------------------------------------
techblog.koponen.se [ / ] [ howto ] [ reviews ] [ webapps ] [ youtube ] [ about ] [ links ] -------------------------------------
HOWTO
STREAMING
HLS STREAMING WITH NGINX-RTMP
Published: 20190228
Updated: 20190705 (some links)
Tested on:
OS: Ubuntu 16.04 (x86_64)
Software:
nginx 1.15.9
homepage
direct download link
backup download link
nginx-rtmp-module
homepage
direct download link
github
backup download link (backup 20190228)
-
Right now this HOWTO only deals with passthru streaming.
It is quite possible to also do live transcoding with this software.
If you only do passthru streaming you need very little resources, a small VM is enough.
1. Building server software
$ sudo apt -y install build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg
$ sudo mkdir /usr/local/source
$ mkdir ~/build
$ cd ~/build
$ wget http://nginx.org/download/nginx-1.15.9.tar.gz
$ wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
$ tar zxvf nginx-1.15.9.tar.gz
$ unzip master.zip
$ cd nginx-1.15.9
$ ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master --prefix=/usr/local/source/nginx-1.15.9
$ make
$ sudo make install
2. Configure NGINX service
$ sudo -i
# cd /usr/local/source/nginx-1.15.9/conf
# mv nginx.conf nginx.conf-dist
# wget http://techblog.koponen.se/howto/streaming/hls-streaming-with-nginx-rtmp/files/nginx.conf
# mkdir /scripts
# cd /scripts
# wget http://techblog.koponen.se/howto/streaming/hls-streaming-with-nginx-rtmp/files/nginx_rtmp_start.sh
# wget http://techblog.koponen.se/howto/streaming/hls-streaming-with-nginx-rtmp/files/nginx_rtmp_stop.sh
# wget http://techblog.koponen.se/howto/streaming/hls-streaming-with-nginx-rtmp/files/nginx_rtmp_restart.sh
# chmod 0755 /scripts/nginx_rtmp_start.sh
# chmod 0755 /scripts/nginx_rtmp_stop.sh
# chmod 0755 /scripts/nginx_rtmp_restart.sh
Put this line in /etc/rc.local (before "exit 0")
/scripts/nginx_rtmp_start.sh
3. How to stream to the server
For the sake of this example, let's assume:
Point your encoder to:
4. How to view the stream from the server
For the sake of this example, let's assume:
You have several options:
You can point a player to the webserver and get a HLS playlist over http
http://server.example.com:80/hls/hellothere.m3u8
(Yes, if it is port 80 it can be shortened to http://server.example.com/hls/hellothere.m3u8)
You can point a player to the raw RTMP stream
rtmp://server.example.com:1935/live
You can point a player to the raw HLS stream
rtmp://server.example.com:1935/hls/hellothere