From f748ff206801304b39b8e3222c5abf9551918713 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Mon, 28 Nov 2022 19:57:52 -0500 Subject: fallback for stream --- roles/stream/templates/emacsconf.nginx.conf | 2 +- roles/stream/templates/icecast.xml | 32 +++++++++++++++++++++++++++-- roles/stream/templates/screen-fallback.sh | 11 ++++++++++ roles/stream/templates/screen-fallbacks | 6 ++++++ roles/stream/templates/screen-restream.sh | 2 +- 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100755 roles/stream/templates/screen-fallback.sh create mode 100755 roles/stream/templates/screen-fallbacks (limited to 'roles/stream/templates') diff --git a/roles/stream/templates/emacsconf.nginx.conf b/roles/stream/templates/emacsconf.nginx.conf index 277c833..ac84ef5 100644 --- a/roles/stream/templates/emacsconf.nginx.conf +++ b/roles/stream/templates/emacsconf.nginx.conf @@ -1,4 +1,4 @@ -location ~ ^/((gen|dev)(-480p)?.webm)$ { +location ~ ^/((gen|dev)(-480p|-fallback)?.webm)$ { proxy_pass http://127.0.0.1:{{ icecast_port }}/$1; proxy_http_version 1.1; proxy_buffering off; diff --git a/roles/stream/templates/icecast.xml b/roles/stream/templates/icecast.xml index d97a515..06830d3 100644 --- a/roles/stream/templates/icecast.xml +++ b/roles/stream/templates/icecast.xml @@ -200,6 +200,8 @@ 1 /usr/local/bin/{{ emacsconf_id }}-lowres-{{ track.id }}-on-connect /usr/local/bin/{{ emacsconf_id }}-lowres-{{ track.id }}-on-disconnect + /{{ track.id }}-sorry.webm + 1 /{{ track.id }}-host.webm @@ -221,6 +223,32 @@ {{ track.watch_lowres }} video/webm 1 + /{{ track.id }}-480p-sorry.webm + 1 + + + /{{ track.id }}-sorry.webm + {{ icecast_emacsconf_user }} + {{ icecast_emacsconf_password }} + EmacsConf {{ emacsconf_year }} - {{ track.name }} - fallback track + The fallback stream for the {{ track.name }} track of {{ emacsconf_name }} {{ emacsconf_year }} + {{ track.watch }} + video/webm + 1 + 1 + + + + /{{ track.id }}-480p-sorry.webm + {{ icecast_emacsconf_user }} + {{ icecast_emacsconf_password }} + EmacsConf {{ emacsconf_year }} - {{ track.name }} - fallback track + The low-res fallback stream for the {{ track.name }} track of {{ emacsconf_name }} {{ emacsconf_year }} + {{ track.watch }} + video/webm + 1 + 1 + {% endfor %} {% if icecast_mounts is defined %} @@ -279,8 +307,8 @@ - access.log - error.log + emacsconf-access.log + emacsconf-error.log 3 10000 diff --git a/roles/stream/templates/screen-fallback.sh b/roles/stream/templates/screen-fallback.sh new file mode 100755 index 0000000..9d816ba --- /dev/null +++ b/roles/stream/templates/screen-fallback.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# {{ ansible_managed }} + +SCREEN_NAME=fallback-{{ mount }} +if screen -S $SCREEN_NAME -Q select ; then + echo "Already running; screen -S $SCREEN_NAME -X quit if you need to restart" +else + echo {{ filename }} - {{ mount }} + screen -dmS $SCREEN_NAME ffmpeg -r 20 -re -fflags +genpts -stream_loop -1 -i /usr/share/icecast2/web/{{ filename }} -map_metadata -1 -f webm -content_type video/webm -c:a copy -c:v copy icecast://{{ icecast_emacsconf_user }}:{{ icecast_emacsconf_password }}@localhost:8001/{{ mount }} + echo "Started screen; connect with screen -x $SCREEN_NAME" +fi diff --git a/roles/stream/templates/screen-fallbacks b/roles/stream/templates/screen-fallbacks new file mode 100755 index 0000000..ade40e1 --- /dev/null +++ b/roles/stream/templates/screen-fallbacks @@ -0,0 +1,6 @@ +#!/bin/bash +# {{ ansible_managed }} +{% for track in emacsconf_tracks %} +/usr/local/bin/screen-fallback-{{ track.id }} & +/usr/local/bin/screen-fallback-{{ track.id }}-480p & +{% endfor %} diff --git a/roles/stream/templates/screen-restream.sh b/roles/stream/templates/screen-restream.sh index 7466c48..e25f574 100755 --- a/roles/stream/templates/screen-restream.sh +++ b/roles/stream/templates/screen-restream.sh @@ -5,6 +5,6 @@ SCREEN_NAME=restream-{{ item[1].name }}-{{ item[0].name }} if screen -S $SCREEN_NAME -Q select ; then echo "Already restreaming; screen -S $SCREEN_NAME -X quit if you need to restart" else - screen -dmS $SCREEN_NAME /home/{{ emacsconf_user }}/restream-{{ item[1].name }}-{{ item[0].name }}e.sh + screen -dmS $SCREEN_NAME /usr/local/bin/restream-{{ item[1].name }}-{{ item[0].name }} echo "Started screen; connect with screen -x $SCREEN_NAME" fi -- cgit v1.2.3