-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
115 lines (98 loc) · 3.55 KB
/
nginx.conf
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
load_module modules/ngx_rtmp_module.so;
# ONLY FOR DOCKER IMAGE!
user root;
# worker_processes auto;
rtmp_auto_push on;
rtmp_socket_dir /run;
error_log /var/log/nginx/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
allow play all;
buflen 500;
# chunk_size 8192;
max_message 32M;
# creates full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
application live {
allow publish all;
live on;
record video;
record_path /tmp;
record_suffix _%Y.%m.%d-%T.flv;
hls on;
hls_nested on;
hls_path /tmp/live;
hls_fragment 2s;
# creates the downsampled video stream
exec_push ffmpeg -i rtmp://127.0.0.1:1935/$app/$name -rtmp_buffer 500 -rtmp_live live -c:v libx264 -preset ultrafast -tune zerolatency -c:a copy -vf scale=-2:480 -f flv rtmp://127.0.0.1:1935/lowres/$name;
# update livestream html on start and end of livestreams
exec_publish /docker-entrypoint.d/gen-live.sh + $name;
exec_publish_done /docker-entrypoint.d/gen-live.sh - $name;
# update vod html when record is done
exec_record_done /docker-entrypoint.d/gen-vod.sh $basename;
}
# creates lower-resolution HLS videostream from the ffmpeg-created stream and tells where to put the HLS video manifest and video fragments
application lowres {
allow publish 127.0.0.1;
deny publish all;
live on;
hls on;
hls_nested on;
hls_path /tmp/lowres;
hls_fragment 2s;
}
# allows to play the recordings of the live streams using a URL like "rtmp://server-ip:1935/vod/filename.flv"
application vod {
play /vod;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
root /srv/;
# creates the http-location for the full-resolution HLS stream - "http://server-ip/live/stream-key/index.m3u8"
location /live {
types {
application/vnd.apple.mpegurl m3u8;
}
alias /tmp/live;
index index.m3u8;
}
# creates the http-location for the low-resolution HLS stream - "http://server-ip/lowres/stream-key/index.m3u8"
location /lowres {
types {
application/vnd.apple.mpegurl m3u8;
}
alias /tmp/lowres;
index index.m3u8;
}
# creates the http-location for the video on demand streams - "http://server-ip/vod/filename.flv"
location /vod {
alias /vod;
index /videos.html;
}
# allows to see stats on connections on the nginx server using a URL like: "http://server-ip/stats"
location = /stats {
stub_status;
}
# allows to see stats on rtmp streams on the nginx server using a URL like: "http://server-ip/stats-rtmp"
location = /stats-rtmp {
rtmp_stat all;
rtmp_stat_stylesheet rtmp_stat.xsl;
}
# allows to get the stats on rtmp streams as raw xml data
location = /stats-rtmp-raw {
rtmp_stat all;
}
# allows to host a webpage which can list the live streams and videos: "http://server-ip/"
location / {
index index.html;
}
}
}