diff options
author | Christian Pointner <equinox@spreadspace.org> | 2021-04-05 01:59:32 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2021-04-05 01:59:32 +0200 |
commit | d6deef93355ed4058c925cdbcec0015c33c99184 (patch) | |
tree | 193dc47a752e09280fac506b3c662f6d96b66ad5 /roles/streaming/rtmp | |
parent | deploy final glt recording hosts (diff) |
use ffmpeg generic segmenter for rtmp/streamer recording feature as well
Diffstat (limited to 'roles/streaming/rtmp')
-rw-r--r-- | roles/streaming/rtmp/streamer/defaults/main.yml | 10 | ||||
-rw-r--r-- | roles/streaming/rtmp/streamer/tasks/main.yml | 23 | ||||
-rw-r--r-- | roles/streaming/rtmp/streamer/templates/pod-spec.yml.j2 | 31 | ||||
-rw-r--r-- | roles/streaming/rtmp/streamer/templates/record.sh.j2 | 9 |
4 files changed, 42 insertions, 31 deletions
diff --git a/roles/streaming/rtmp/streamer/defaults/main.yml b/roles/streaming/rtmp/streamer/defaults/main.yml index 95a2ecc2..6d66683a 100644 --- a/roles/streaming/rtmp/streamer/defaults/main.yml +++ b/roles/streaming/rtmp/streamer/defaults/main.yml @@ -12,12 +12,16 @@ rtmp_streamer_app_name: "{{ rtmp_streamer_inst_name }}" rtmp_streamer_quality_levels: - full -rtmp_streamer_recording_enabled: no -rtmp_streamer_recording_level: full +rtmp_streamer_config: {} + rtmp_streamer_forwards: {} # example: # url: rtmp://ingest.example.com/foo/secret # level: full -rtmp_streamer_config: {} + +# rtmp_streamer_recording: +# level: full +# segment_time: 7200 +# segment_clocktime_offset: 0 diff --git a/roles/streaming/rtmp/streamer/tasks/main.yml b/roles/streaming/rtmp/streamer/tasks/main.yml index c5caf471..1715bdf9 100644 --- a/roles/streaming/rtmp/streamer/tasks/main.yml +++ b/roles/streaming/rtmp/streamer/tasks/main.yml @@ -21,21 +21,13 @@ content: "{{ rtmp_streamer_config | combine({'rtmp_base_url': 'rtmp://127.0.0.1/'+rtmp_streamer_app_name}) | to_nice_yaml }}\n" dest: "{{ rtmp_streamer_base_path }}/{{ rtmp_streamer_inst_name }}/config.yml" -- name: enable recording - when: rtmp_streamer_recording_enabled | bool - block: - - name: create recording directory - file: - path: "{{ rtmp_streamer_base_path }}/{{ rtmp_streamer_inst_name }}/recordings" - state: directory - owner: app - group: app - - - name: generate recording script - template: - src: record.sh.j2 - dest: "{{ rtmp_streamer_base_path }}/{{ rtmp_streamer_inst_name }}/record.sh" - mode: 0755 +- name: create recording directory + when: rtmp_streamer_recording is defined + file: + path: "{{ rtmp_streamer_base_path }}/{{ rtmp_streamer_inst_name }}/recordings" + state: directory + owner: app + group: app - name: install pod manifest vars: @@ -49,6 +41,5 @@ - path: "{{ rtmp_streamer_base_path }}/{{ rtmp_streamer_inst_name }}/config.yml" properties: - checksum - ## TODO: add record.sh if recording is enabled include_role: name: kubernetes/standalone/pod diff --git a/roles/streaming/rtmp/streamer/templates/pod-spec.yml.j2 b/roles/streaming/rtmp/streamer/templates/pod-spec.yml.j2 index ec51ed14..329267bc 100644 --- a/roles/streaming/rtmp/streamer/templates/pod-spec.yml.j2 +++ b/roles/streaming/rtmp/streamer/templates/pod-spec.yml.j2 @@ -75,12 +75,37 @@ containers: - "{{ forward.url }}" {% endfor %} -{% if rtmp_streamer_recording_enabled %} +{% if rtmp_streamer_recording is defined %} - name: record image: registry.gitlab.com/spreadspace/docker/nginx:{{ rtmp_streamer_nginx_image_version }} imagePullPolicy: Always + command: + - /usr/bin/ffmpeg args: - - /srv/record.sh + - -f + - live_flv + - -rtmp_live + - live + - -i + - 'rtmp://127.0.0.1/{{ rtmp_streamer_app_name }}/{{ rtmp_streamer_recording.level }}' + - -c:a + - copy + - -c:v + - copy + - -f + - segment + - -segment_atclocktime + - '1' + - -segment_time + - '{{ rtmp_streamer_recording.segment_time | default(3600) }}' + - -segment_clocktime_offset + - '{{ rtmp_streamer_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 @@ -103,7 +128,7 @@ volumes: hostPath: type: Directory path: /usr/lib/ -{% if rtmp_streamer_recording_enabled %} +{% if rtmp_streamer_recording is defined %} - name: recordings hostPath: type: Directory diff --git a/roles/streaming/rtmp/streamer/templates/record.sh.j2 b/roles/streaming/rtmp/streamer/templates/record.sh.j2 deleted file mode 100644 index 159bf5e2..00000000 --- a/roles/streaming/rtmp/streamer/templates/record.sh.j2 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -BASE_D="/srv/recordings" -DAY=$(date '+%Y-%m-%d') -TIME=$(date '+%H-%M-%S') - -umask 022 -mkdir -p "$BASE_D/$DAY" -exec /usr/bin/ffmpeg -f live_flv -rtmp_live live -i "rtmp://127.0.0.1/{{ rtmp_streamer_app_name }}/{{ rtmp_streamer_recording_level }}" -c:a copy -c:v copy -f matroska "$BASE_D/$DAY/$DAY""_$TIME.mkv" |