diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-11-21 14:32:08 -0500 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-11-21 14:32:08 -0500 |
commit | 4fe95f44f002a0399f8e31a93e9425edf40a9671 (patch) | |
tree | 1663b8ed53505d1d23d4e4b5a5d52c5b537000d2 /roles/stream | |
parent | 4d1100b931a0d921883a66f857fd89999fb63a3e (diff) | |
download | emacsconf-ansible-4fe95f44f002a0399f8e31a93e9425edf40a9671.tar.xz emacsconf-ansible-4fe95f44f002a0399f8e31a93e9425edf40a9671.zip |
restreaming
Diffstat (limited to 'roles/stream')
-rw-r--r-- | roles/stream/tasks/main.yml | 37 | ||||
-rw-r--r-- | roles/stream/tasks/track.yml | 17 | ||||
-rwxr-xr-x | roles/stream/templates/restream.sh | 18 |
3 files changed, 45 insertions, 27 deletions
diff --git a/roles/stream/tasks/main.yml b/roles/stream/tasks/main.yml index d741c72..941ac92 100644 --- a/roles/stream/tasks/main.yml +++ b/roles/stream/tasks/main.yml @@ -13,27 +13,8 @@ path: "{{ icecast_restream_dir }}" owner: "{{ icecast_user }}" state: directory -- name: Debug - debug: - var: item.id - loop: "{{ emacsconf_tracks }}" -- name: Copy the lowres restreaming shell script - template: - src: lowres.sh - dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}.sh - mode: 0755 - loop: "{{ emacsconf_tracks }}" -- name: Copy lowres on-connect - template: - src: on-connect - dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}-on-connect - mode: 0755 - loop: "{{ emacsconf_tracks }}" -- name: Copy lowres on-disconnect - template: - src: on-disconnect - dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}-on-disconnect - mode: 0755 +- name: Set up track-specific things + include: track.yml loop: "{{ emacsconf_tracks }}" - name: Set up init file become: true @@ -73,9 +54,11 @@ - name: Try to restart icecast if not started service: name=emacsconf state=started enabled=yes when: port_check.failed == true -# - name: Set up restream script -# template: -# src: restream-yt.sh -# dest: /home/orga/restream-yt.sh -# owner: orga -# mode: 0755 +- name: Set up restream scripts + tags: restream + template: + src: restream.sh + dest: /home/orga/restream-{{ item[1].name }}-{{ item[0].name }}.sh + owner: orga + mode: 0755 + loop: "{{ restreaming_platforms | subelements('streams') | list }}" diff --git a/roles/stream/tasks/track.yml b/roles/stream/tasks/track.yml new file mode 100644 index 0000000..d1e8204 --- /dev/null +++ b/roles/stream/tasks/track.yml @@ -0,0 +1,17 @@ +- name: Copy the lowres restreaming shell script + template: + src: lowres.sh + dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}.sh + mode: 0755 +- name: Copy lowres on-connect + template: + src: on-connect + dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}-on-connect + mode: 0755 +- name: Copy lowres on-disconnect + template: + src: on-disconnect + dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}-on-disconnect + mode: 0755 + + diff --git a/roles/stream/templates/restream.sh b/roles/stream/templates/restream.sh new file mode 100755 index 0000000..e1d0a7f --- /dev/null +++ b/roles/stream/templates/restream.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# {{ ansible_managed }} +MOUNT={{ item[0].stream_url }}/{{ item[1].key }} # rtmp://..../stream_key +LOGLEVEL="${LOGLEVEL:-24}" +for i in 1 2 3 4 5; do + ffmpeg -re -loglevel $LOGLEVEL -i http://localhost:{{ icecast_port }}/{{ emacsconf_id }}/{{ item[1].source }} \ + -cluster_size_limit 2M \ + -cluster_time_limit 5100 \ + -b:v 1M \ + -crf 30 \ + -g 125 \ + -deadline re \ + -threads 4 \ + -vcodec libx264 \ + -acodec libmp3lame \ + -f flv $MOUNT + sleep 5 # in case of error +done |