Here is a Very Easy Guide For Streaming Video, Audio on Demand with Nginx on HP Cloud Using RTMP Protocol, Which is Needed For YouTube Live. This guide does not requires VLC Player unlike we described before, Wowza Player or any other web software. This is very easy and highly scalable. We are using Nginx Community Edition. Nginx Plus has some extra features for streaming. RTMP Protocol is Real Time Streaming Protocol. VLC Player supports RTMP protocol so you can play to test it directly from VLC menu > Media-> Open Network Stream.
Google servers will catch the stream and Geographically distribute for Free of cost. We are basically magnifying 1 GB server to huge resource plus the chance of money making is present on YouTube Live.
Streaming Video, Audio on Demand with Nginx : Pre-requisite For HP Cloud
We have written the guide for Ubuntu server 14.04 LTS. However, it is basically server OS independent. Real Time Messaging Protocol (RTMP) is a TCP-based protocol which maintains persistent connections and is defined as a stateful protocol. HTTP is a stateless application protocol.
---
As we need to open Port 1935, you should configure the virtual router in HP Cloud rightly and set proper ingress-egress policy.
Streaming Video, Audio on Demand with Nginx : Compatibility With Rackspace Cloud
Rackspace Cloud is not intent ended for corporate setup, hence has no virtual router by default. Readers need not to follow the Pre-requisite For HP Cloud paragraph written above. However, their operating system can block via Firewall. Test with VLC player.
Streaming Video, Audio on Demand with Nginx : Commands
You can check this git which has ready to use 1 step command to run a bash script to do the works :
1 | https://github.com/upggr/UPG.GR-MEDIA-SERVER |
The git is good but needs some work, has no clear cut License. It is your matter use or not use. We have to describe in classical way. For so few commands, you may use the commands & use the settings files from the git.
nginx-extras
comes with Nginx RTMP module, so you do not need to compile & build from source. After login to the server via SSH as root user, just install nginx-extras
:
1 | apt-get install nginx-extras |
If you want to compile from source then run :
1 2 3 4 5 6 7 8 9 | apt update -y && apt upgrade -y apt-get install git gcc make libpcre3-dev libssl-dev cd ~ && mkdir nginx cd nginx && git clone https://github.com/arut/nginx-rtmp-module # check nginx latest - http://nginx.org/en/download.html wget http://nginx.org/download/nginx-1.8.0.tar.gz && tar zxpvf nginx* cd nginx* && ./configure --add-module=/root/nginx/nginx-rtmp-module/ --with-http_ssl_module --prefix=/usr/local/nginx-streaming/ make make install |
We have tested with compiled version, so :
1 2 | cd /usr/local/nginx-streaming/conf && mv nginx.conf nginx_config.backup nano nginx.conf |
Like normal web server, we need to set it rightly :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | user www-data; worker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4000; # vod for flv files application vod { play /var/flvs; } # vod for mp4 files application vod2 { play /var/mp4s; } } } # HTTP can be used for accessing RTMP stats http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log debug; server { # normal web server on port 80 listen 8080; server_name localhost; # RTMP statistics in XML location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { # Copy stat.xsl wherever you want # and put the full directory path here root /var/www/; } location /hls { # HLS fragments types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /tmp/app; expires -1; } } } |
Then copy the xml file :
1 | mkdir /var/www && cp /root/nginx/nginx-rtmp-module/stat.xsl /var/www/ |
Restart nginx web server. If you wget some FLV files at /var/flvs
, you will see on this path it is streaming :
1 | rtmp://IP.OF.THE.SERVER:1935/vod2/yourfile.flv |
Base is usually /vod2/
but you probably need checking the Git of the module for more settings :
1 2 | https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp https://github.com/arut/nginx-rtmp-module |