-
Notifications
You must be signed in to change notification settings - Fork 4
/
nginx.tmp.conf
115 lines (91 loc) · 3.63 KB
/
nginx.tmp.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
rtmp {
server {
listen 1935;
#chunk_size 4000;
chunk_size 4096;
# This application is to accept incoming stream
application live {
live on; # Allows live input
# Once receive stream, transcode for adaptive streaming
# This single ffmpeg command takes the input and transforms
# the source into 4 different streams with different bitrate
# and quality. P.S. The scaling done here respects the aspect
# ratio of the input.
exec ffmpeg -i rtmp://localhost/$app/$name -async 1 -vsync -1
-c:v libx264 -c:a libmp3lame -b:v 256k -b:a 32k -vf "scale=352:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_sd240p
-c:v libx264 -c:a libmp3lame -b:v 768k -b:a 96k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_360p
-c:v libx264 -c:a libmp3lame -b:v 1024k -b:a 128k -vf "scale=858:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_480p
-c:v libx264 -c:a libmp3lame -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_hd720p;
#-c copy -f flv rtmp://localhost/show/$name_src;
}
# HLS
# For HLS to work please create a directory in tmpfs (/tmp/hls here)
# for the fragments. The directory contents is served via HTTP (see
# http{} section in config)
#
# Incoming stream must be in H264/AAC. For iPhones use baseline H264
# profile (see ffmpeg example).
# This example creates RTMP stream from movie ready for HLS:
#
# ffmpeg -loglevel verbose -re -i movie.avi -vcodec libx264
# -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1
# -f flv rtmp://localhost:1935/hls/movie
#
# If you need to transcode live stream use 'exec' feature.
#
application show {
live on;
wait_key on;
dash on;
dash_nested on;
dash_path /data/dash;
dash_fragment 1s;
dash_playlist_length 5s;
dash_variant _sd240p BANDWIDTH="288000" width="352" height="240";
dash_variant _360p BANDWIDTH="448000" width="480" height="360";
dash_variant _480p BANDWIDTH="1152000" width="858" height="480";
dash_variant _hd720p BANDWIDTH="2048000" width="1280" height="720";
hls on;
hls_nested off;
hls_type live;
hls_path /data/hls;
hls_fragment 3s;
hls_playlist_length 10s;
# Instruct clients to adjust resolution according to bandwidth
hls_variant _sd240p BANDWIDTH=288000;
hls_variant _360p BANDWIDTH=448000;
hls_variant _480p BANDWIDTH=1152000;
hls_variant _hd720p BANDWIDTH=2048000;
}
}
}
server {
listen 80 default_server;
server_name _;
root /data;
location / {
# Disable cache
if_modified_since off;
etag off;
add_header Last-Modified "";
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Allow-Headers' 'Range';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}