summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-11-21 14:32:08 -0500
committerSacha Chua <sacha@sachachua.com>2022-11-21 14:32:08 -0500
commit4fe95f44f002a0399f8e31a93e9425edf40a9671 (patch)
tree1663b8ed53505d1d23d4e4b5a5d52c5b537000d2
parent4d1100b931a0d921883a66f857fd89999fb63a3e (diff)
downloademacsconf-ansible-4fe95f44f002a0399f8e31a93e9425edf40a9671.tar.xz
emacsconf-ansible-4fe95f44f002a0399f8e31a93e9425edf40a9671.zip
restreaming
-rw-r--r--README.org3
-rw-r--r--roles/media/templates/nginx-include4
-rwxr-xr-xroles/prerec/templates/thumbnail.sh3
-rwxr-xr-xroles/prerec/templates/update-emacsconf.sh6
-rw-r--r--roles/stream/tasks/main.yml37
-rw-r--r--roles/stream/tasks/track.yml17
-rwxr-xr-xroles/stream/templates/restream.sh18
7 files changed, 60 insertions, 28 deletions
diff --git a/README.org b/README.org
index 2394f54..80b322e 100644
--- a/README.org
+++ b/README.org
@@ -206,6 +206,9 @@ ansible-playbook -i inventory.yml prod-playbook.yml --tags obs-scene
Update scenes from the dev copy:
ssh emacsconf-dev@res.emacsconf.org "cat ~/.config/obs-studio/basic/scenes/dev.json" | jq 'walk(if type == "string" then gsub("emacsconf"; "{{ emacsconf_id }}") | gsub("dev"; "{{ item.id }}") else . end)' > scenes.json
+* Media
+
+ansible-playbook -i inventory.yml prod-playbook.yml --tags media
* Captioning
Set up whisper:
diff --git a/roles/media/templates/nginx-include b/roles/media/templates/nginx-include
index 3bfb58e..f61d5c5 100644
--- a/roles/media/templates/nginx-include
+++ b/roles/media/templates/nginx-include
@@ -1,4 +1,6 @@
- location /{{ emacsconf_year }}/backstage {
+rewrite ^/current/bbb-open.html$ {{ bbb_open_url }} redirect;
+
+location /{{ emacsconf_year }}/backstage {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/sites-available/{{ host_name }}-{{ emacsconf_year }}-htpasswd;
autoindex on;
diff --git a/roles/prerec/templates/thumbnail.sh b/roles/prerec/templates/thumbnail.sh
new file mode 100755
index 0000000..436979d
--- /dev/null
+++ b/roles/prerec/templates/thumbnail.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+# {{ ansible_managed }}
+ffmpeg -i "$1" -vf "thumbnail,scale=400:225" -frames:v 1 $(echo "$1" | sed s/webm/png/ )
diff --git a/roles/prerec/templates/update-emacsconf.sh b/roles/prerec/templates/update-emacsconf.sh
new file mode 100755
index 0000000..e01ebcf
--- /dev/null
+++ b/roles/prerec/templates/update-emacsconf.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+# {{ ansible_managed }}
+
+cd {{ emacsconf_el_dir }}
+git pull
+emacsclient --eval "(emacsconf-reload)" -a emacs
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