summaryrefslogtreecommitdiff
path: root/roles/streaming/streamer/rtmp/templates/pod-spec.yml.j2
blob: 81058cea053f2c44497ce2da6011ab2867dbeafe (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
containers:
- name: nginx
  image: registry.gitlab.com/spreadspace/docker/nginx:{{ streamer_rtmp_nginx_image_version }}
  imagePullPolicy: Always
  command:
  - nginx
  args:
  - -c
  - /srv/nginx.conf
  - -g
  - "daemon off;"
  ports:
  - containerPort: 1935
    hostPort: {{ streamer_rtmp_port }}
  volumeMounts:
  - name: home
    mountPath: /srv
    readOnly: true
  - name: nginx-lib
    mountPath: /var/lib/nginx

- name: source
  image: registry.gitlab.com/spreadspace/docker/ffmpeg:{{ streamer_rtmp_ffmpeg_image_version }}
  imagePullPolicy: Always
  command:
  - /usr/local/bin/generic-rtmp.py
  args:
{% for param in streamer_rtmp_input %}
  - '{{ param }}'
{% endfor %}
  env:
  - name: CONFIG_FILENAME
    value: /srv/config.yml
  - name: QUALITY_LEVELS
    value: {{ streamer_rtmp_quality_levels | join(',') }}
  - name: AUDIO_TRACKS
    value: {{ streamer_rtmp_audio_track }}
{% if streamer_rtmp_video_filter_common is defined %}
  - name: VIDEO_FILTER_COMMON
    value: "{{ streamer_rtmp_video_filter_common }}"
{% endif %}
  securityContext:
    privileged: true
  volumeMounts:
  - name: home
    mountPath: /srv
    readOnly: true
  - name: decklink-device
    mountPath: /dev/blackmagic
  - name: decklink-libs
    subPath: libDeckLinkAPI.so
    mountPath: /usr/lib/libDeckLinkAPI.so
    readOnly: true
  - name: decklink-libs
    subPath: libDeckLinkPreviewAPI.so
    mountPath: /usr/lib/libDeckLinkPreviewAPI.so
    readOnly: true
  - name: decklink-libs
    subPath: blackmagic
    mountPath: /usr/lib/blackmagic
    readOnly: true

{% for name, forward in streamer_rtmp_forwards.items()  %}
- name: "forward-{{ name }}"
  image: registry.gitlab.com/spreadspace/docker/ffmpeg:{{ streamer_rtmp_ffmpeg_image_version }}
  imagePullPolicy: Always
  command:
  - /usr/bin/ffmpeg
  args:
  - -f
  - live_flv
  - -rtmp_live
  - live
  - -i
  - 'rtmp://127.0.0.1/{{ streamer_rtmp_app_name }}/{{ forward.level }}'
  - -c:a
  - copy
  - -c:v
  - copy
  - -f
  - flv
  - '{{ forward.url }}'

{% endfor %}
{% if streamer_rtmp_recording is defined %}
- name: record
  image: registry.gitlab.com/spreadspace/docker/ffmpeg:{{ streamer_rtmp_ffmpeg_image_version }}
  imagePullPolicy: Always
  command:
  - /usr/bin/ffmpeg
  args:
  - -f
  - live_flv
  - -rtmp_live
  - live
  - -i
  - 'rtmp://127.0.0.1/{{ streamer_rtmp_app_name }}/{{ streamer_rtmp_recording.level }}'
  - -c:a
  - copy
  - -c:v
  - copy
  - -f
  - segment
  - -segment_atclocktime
  - '1'
  - -segment_time
  - '{{ streamer_rtmp_recording.segment_time | default(3600) }}'
  - -segment_clocktime_offset
  - '{{ streamer_rtmp_recording.segment_clocktime_offset | default(0) }}'
  - -strftime
  - '1'
  - -reset_timestamps
  - '1'
  - '%Y-%m-%d_%H-%M-%S.mkv'
  workingDir: /srv/recordings
  volumeMounts:
  - name: home
    mountPath: /srv
    readOnly: true
  - name: recordings
    mountPath: /srv/recordings

{% endif %}
volumes:
- name: home
  hostPath:
    path: "{{ streamer_rtmp_base_path }}/{{ streamer_rtmp_inst_name }}"
- name: nginx-lib
  emptyDir:
    medium: Memory
- name: decklink-device
  hostPath:
    path: /dev/blackmagic
- name: decklink-libs
  hostPath:
    type: Directory
    path: /usr/lib/
{% if streamer_rtmp_recording is defined %}
- name: recordings
  hostPath:
    type: Directory
    path: "{{ streamer_rtmp_base_path }}/{{ streamer_rtmp_inst_name }}/recordings"
{% endif %}