summaryrefslogtreecommitdiff
path: root/templates/default/kubernetes/nginx-streamer-cm.yml.j2
blob: 41713054ee4744be0ba0e03f3f33d761d2bf3416 (plain) (blame)
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
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: {{ namespace }}
  name: nginx-streamer-{{ worker.name }}
  labels:
    app: nginx
    type: streamer
    worker: {{ worker.name }}
data:
  nginx.conf: |
    worker_processes 4;
    pid /srv/nginx.pid;
    error_log /dev/stderr notice;

    load_module modules/ngx_rtmp_module.so;

    events {
      worker_connections 768;
      # multi_accept on;
    }

    http {
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 65;
      types_hash_max_size 2048;

      server_names_hash_bucket_size 64;

      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      access_log /dev/null;

      server {
        listen 8000 default_server;
        listen [::]:8000 default_server;
        server_name _;

        root /srv/www;

        location / {
          types {
            application/vnd.apple.mpegurl m3u8;
          }
          expires -1s;
          add_header Cache-Control "no-store,must-revalidate,max-age=0";
        }
      }
    }

    rtmp {
      access_log /dev/null;

      server {
        listen localhost:1935;

        respawn on;

        exec_static ffmpeg -i http://flumotion-worker-{{ worker.name }}:8000/av-orig-flash-mini.flv
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/hls/av-orig-mini
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/dash/av-orig-mini;
        exec_static ffmpeg -i http://flumotion-worker-{{ worker.name }}:8000/av-orig-flash-low.flv
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/hls/av-orig-low
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/dash/av-orig-low;
        exec_static ffmpeg -i http://flumotion-worker-{{ worker.name }}:8000/av-orig-flash-medium.flv
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/hls/av-orig-medium
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/dash/av-orig-medium;
        exec_static ffmpeg -i http://flumotion-worker-{{ worker.name }}:8000/av-orig-flash-high.flv
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/hls/av-orig-high
              -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f flv rtmp://localhost/dash/av-orig-high;

        application hls {
          live on;

          hls on;
          hls_path /srv/www/hls;
          hls_fragment 3;
          hls_playlist_length 12;
          hls_nested on;
          hls_cleanup on;
          hls_fragment_naming timestamp;
          hls_fragment_slicing aligned;
          hls_type live;
          hls_base_url http://localhost:8000/hls/;

          hls_variant -mini    BANDWIDTH=350000;
          hls_variant -low     BANDWIDTH=700000;
          hls_variant -medium  BANDWIDTH=1200000;
          hls_variant -high    BANDWIDTH=2000000;
        }

        application dash {
          live on;

          dash on;
          dash_path /srv/www/dash;
          dash_fragment 3;
          dash_playlist_length 12;
          dash_nested on;
          dash_cleanup on;
        }
      }
    }