-
Notifications
You must be signed in to change notification settings - Fork 3
/
create-nginx-conf.sh
executable file
·71 lines (54 loc) · 1.45 KB
/
create-nginx-conf.sh
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
#!/bin/bash
SECRET=$RTMP_SECRET
if [ "$SECRET" == "" ]; then
SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
fi
PERISCOPE_CONFIG=""
if [ "$RTMP_PERISCOPE_ENABLED" == "true" ] && [ "$RTMP_PERISCOPE_KEY" != "" ]; then
PERISCOPE_CONFIG="
# Periscope transcoding
exec ffmpeg -i rtmp://127.0.0.1/live/\$name -crf 30 -preset ultrafast -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 64k -vcodec libx264 -x264-params keyint=60:no-scenecut=1 -r 30 -b:v 500k -s 1280x720 -f flv $RTMP_PERISCOPE_SERVER$RTMP_PERISCOPE_KEY;
"
fi
TWITCH_CONFIG=""
if [ "$RTMP_TWITCH_ENABLED" == "true" ] && [ "$RTMP_TWITCH_KEY" != "" ]; then
TWITCH_CONFIG="
# Twitch
push $RTMP_TWITCH_SERVER$RTMP_TWITCH_KEY;
"
fi
FACEBOOK_CONFIG=""
if [ "$RTMP_FACEBOOK_ENABLED" == "true" ] && [ "$RTMP_FACEBOOK_KEY" != "" ]; then
FACEBOOK_CONFIG="
# Facebook
push $RTMP_FACEBOOK_SERVER$RTMP_FACEBOOK_KEY;
"
fi
YOUTUBE_CONFIG=""
if [ "$RTMP_YOUTUBE_ENABLED" == "true" ] && [ "$RTMP_YOUTUBE_KEY" != "" ]; then
YOUTUBE_CONFIG="
# YouTube
push $RTMP_YOUTUBE_SERVER$RTMP_YOUTUBE_KEY;
"
fi
TEMPLATE="
worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
server {
listen 1935;
listen [::]:1935 ipv6only=on;
application live {
live on;
record off;
on_publish $RTMP_AUTH_SERVER;
$PERISCOPE_CONFIG
$TWITCH_CONFIG
$FACEBOOK_CONFIG
$YOUTUBE_CONFIG
}
}
}
"
echo "$TEMPLATE" > $1