Escolar Documentos
Profissional Documentos
Cultura Documentos
Ablogaboutwebhostingandsoftwaredevelopment
cd~
mkdirnginx
cdnginx
#forcompilerandgit
aptgetinstallgitgccmake
#fortheHTTPrewritemodulewhichrequiresthePCRElibrary
aptgetinstalllibpcre3dev
#forSSLmodules
aptgetinstalllibssldev
gitclonehttps://github.com/arut/nginxrtmpmodule
Download the Nginx source code and extract it from the archive. At the time when
we are writing this blog post, the current version is 1.4.3:
1
2
3
wgethttp://nginx.org/download/nginx1.4.3.tar.gz
tarzxpvfnginx1.4.3.tar.gz
cdnginx1.4.3
./configureaddmodule=/root/nginx/nginxrtmpmodule/withhttp_ssl_moduleprefix=/usr/local
make
makeinstall
cd/usr/local/nginxstreaming/conf
mvnginx.confnginx.cong.bkp
nanonginx.conf
worker_processes1
events{
worker_connections1024
}
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
rtmp{
server{
listen1935
chunk_size4000
#videoondemandforflvfiles
applicationvod{
play/var/flvs
}
#videoondemandformp4files
applicationvod2{
play/var/mp4s
}
}
}
#HTTPcanbeusedforaccessingRTMPstats
http{
access_log/var/log/nginx/accessstreaming.log
error_log/var/log/nginx/errorstreaming.log
server{
#incasewehaveanotherwebserveronport80
listen8080
#ThisURLprovidesRTMPstatisticsinXML
location/stat{
rtmp_statall
rtmp_stat_stylesheetstat.xsl
}
location/stat.xsl{
#XMLstylesheettoviewRTMPstats.
#Copystat.xslwhereveryouwant
#andputthefulldirectorypathhere
root/var/www/
}
location/hls{
#ServeHLSfragments
types{
application/vnd.apple.mpegurlm3u8
video/mp2tts
}
alias/tmp/app
expires1
}
}
}
To be able to see some nice statistics about the streaming, we must to copy stats.xml
in the folder specified in the configuration above.
1
2
mkdir/var/www
cp/root/nginx/nginxrtmpmodule/stat.xsl/var/www/
/usr/local/nginxstreaming/sbin/nginx
Now, if you have a video player which supports RTMP protocol (eg: VLC), you can
play it directly there.
From the VLC menu, Media->Open Network Stream.
In the URL field we input:
1
rtmp://<IP_OF_THE_SERVER>:1935/vod2/sample.mp4
If you want to show this video on a website, you can use a flash player as
Flowplayeror JW Player.
Below we will show how to use Flowplayer to achieve this. First we need to
download flowplayer.rtmp-3.2.12.swf (see the download link at the bottom of the
page).
The html code below shows how to implement RTMP using Flowplayer. You should
just replace the /path/to/background.png, the<IP_OF_THE_SERVER>and the
/path/to/flowplayer.rtmp-3.2.12.swf.
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
<html>
<head>
<!flowplayerjavascriptcomponent>
<scriptsrc="http://releases.flowplayer.org/js/flowplayer3.2.12.min.js"></script>
</head>
<body>
<divid="player"style="width:644pxheight:276pxmargin:0autotextalign:center">
<imgsrc="/path/to/background.png"height="260"width="489"/></div>
<script>
$f("player","http://releases.flowplayer.org/swf/flowplayer3.2.16.swf",{
clip:{
url:'sample.mp4',
scaling:'fit',
provider:'hddn'
},
plugins:{
hddn:{
url:"/path/to/flowplayer.rtmp3.2.12.swf",
//netConnectionUrldefineswherethestreamsarefound
netConnectionUrl:'rtmp://<IP_OF_THE_SERVER>:1935/vod2'
}
},
canvas:{
backgroundGradient:'none'
}
})
</script>
</body>
</html>
Thats all.
Of course the solution presented in the post above is minimalist and if you need to
scale globally with your Video on Demand product, probably you need a CDN
solution.
Yoga Darma
December4,2013at9:14am
hi, im trying to make streaming VOD that running on web. im using your HTML
code but it doesnt want to running the video. but when i using vlc its working. can
you please help me? sorry i cant speak English well. thank you
@Yoga: Please share some more information about you Nginx configuration, without
that it is hard to help you.
Yoga Darma
December6,2013at9:20am
@Maurits i only follow this tutorial. so my configuration will be the same as this
tutorials configuration. am i doing something wrong ??if yes can you tell me what it
is??
thank you so much
Yoga Darma
December6,2013at9:29am
@Razvan Tudorica : maybe i should try the HLS streaming. can you tell me what is
the difference? and why my HTML code is not working? i doing all your instruction
in this tutorial. thats make me curious. thank you so much
inan
January12,2014at10:28pm
Hey,
nice tutorial great job. Its possible to secure the streaming? Maybe with htaccess or
whatever
inan
January12,2014at10:49pm
Hey me again
When im typing the command make i get a error like this: make: *** No rule to
make target `build, needed by `default. Stop
How can i solve this problem?
inan
January13,2014at8:54am
Hello,
i solved the Problem. I was in the wrong directory
Its possible to restream from my Live stream from my VLC Server?
razvan
January22,2014at10:55am
Hi inan,
You can secure your stream as described in this blog post
http://rarut.wordpress.com/2013/06/09/secure-links-in-nginx-rtmp/ written by the
author of the rtmp modules.
Jamie M.
February17,2014at6:26pm
When I stream from OBS to my nginx rtmp VPS server occasionally itll lose contact
with nginx. The only way to get it to connect back to nginx is to sudo killall -9
nginx then sudo /usr/local/nginx/sbin/nginx and tada, OBS reconnects
automatically and starts streaming again like a champ.
Can you let me know any specific way to test and see whats going on with nginx?
-Jamie M.
david
February27,2014at10:33pm
Hi, Great tutorial thanks, only problem I have is when I try to start the NGINX server
I get the following error..
nginx: [emerg] unknown directive worker_processes in /usr/local/nginxstreaming//conf/nginx.conf:1
Any ideas why..?
Mazen
April16,2014at11:55am
Pingback: ggkf
WowzaAdmirer
October14,2014at10:55am
Thanks for a post. Ive been using WMSPanel which is a reporting panel for media
servers and now I see that they support reporting for nginx-rtmp-module. I hope this
will be useful for you guys: https://wmspanel.com/nginx
Tim Beyer
December14,2014at7:03pm
Hey there,
I have setup nginx with the rtmp-module on an Ubuntu machine. Right now my
rtmp section looks like this and works perfect:
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
push rtmp://server/app/key;
}
}
}
The thing is I dont want it to drop the stream when someone disconnects with OBS.
Instead I want to hold it at least with a black screen, image or better, to play
randomly local files from the server. Now I have for testing purposes a .mp4
uploaded to var/mp4s, but havent been able yet to make it working. Could you
maybe help me out on this one?
In general I want to make it stream 24/7 if someone connects with a livestream it
stops the videofile playing and lets the live-stream through. If the streamer
disconnects it plays again randomly files from the above folder.
Hopefully youve an idea how to do this.
Thanks in advance!
Best,
Tim
@Tim: Thanks for your comment. It seems like you have a good setup already. What
player are you using? Cant you implement a smart player that detects the stream
(un)availability and gets another playlist on failure? That is probably the way that I
would go.
Tim Beyer
December16,2014at1:29am
Robin
December29,2014at8:47pm
@Robin: Thank you for your comment. I know FMS and Red5 support RTMPS, but I
am not aware of a solution for Nginx. I suppose just terminating the SSL in a reverse
proxy setup wont work or did you not try that (yet)? Sorry that I cant help you
better. Keep us posted on the solution!
Arjun
April22,2015at10:54am
Do anyone know how to get the published stream name in config file?
Ioannis
July25,2015at8:47pm
Hi,
Try my project for this https://github.com/upggr/UPG.GR-MEDIA-SERVER
Easier, a single command and you are done
@Ioannis: Thank you for this link. Im going to have a look at it!
Rizal
July30,2015at4:41am
Thor
September17,2015at9:10pm
Im trying to figure out what @Tim was trying to do. Anyone end up finding out how
to make the application automatically play files from /var/mp4s when there a live
feed isnt active?
Harpreet
November6,2015at9:08pm
Hi,
Thanks for such details information.
I followed the instructions and setup Nginx-rtmp on my ubuntu 14.04 system. Nginx
server is working fine as it is showing me default Nginx page on localhost.
But RTMP is not working, neither through VLC nor web player.
Following is my config :
#user nobody;
worker_processes 1;
error_log /var/log/nginx/nginx_error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
user www-data www-data;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
# video on demand for flv files
application vod {
play /var/flvs;
}
kunal
November22,2015at5:43am
Hi,
this is really a good tutorial about the VOD on Demand. but i have a question if you
might can help me.
I am looking for a way to deal with MXF Files to first convert into MP4 and then Play
within VLC Player.
suppose if a user open a vlc Player and wants to Play the VIdeo
rtmp://10.30.0.345:1935/vod/video-ID01
can we do that ?
any help will be really Helpful. thanks