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 --- README.org | 9 +- roles/stream/files/sorry-480p.webm | Bin 0 -> 43389 bytes roles/stream/files/sorry.png | Bin 0 -> 138008 bytes roles/stream/files/sorry.svg | 339 ++++++++++++++++++++++++++++ roles/stream/files/sorry.webm | Bin 0 -> 66085 bytes roles/stream/tasks/main.yml | 26 ++- roles/stream/tasks/track.yml | 22 +- 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 +- 12 files changed, 438 insertions(+), 11 deletions(-) create mode 100644 roles/stream/files/sorry-480p.webm create mode 100644 roles/stream/files/sorry.png create mode 100644 roles/stream/files/sorry.svg create mode 100644 roles/stream/files/sorry.webm create mode 100755 roles/stream/templates/screen-fallback.sh create mode 100755 roles/stream/templates/screen-fallbacks diff --git a/README.org b/README.org index 80b322e..57d8094 100644 --- a/README.org +++ b/README.org @@ -189,6 +189,11 @@ ansible-playbook -i inventory.yml prod-playbook.yml --tags test -e icecast_test_ Use a test pattern (don't know if this works) ansible-playbook -i inventory.yml prod-playbook.yml --tags test -e icecast_test_track=dev -e icecast_test=pattern +** Creating the fallback files +ffmpeg -y -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -loop 1 -r 20 -t 10 -i sorry.png -c:v libvpx -c:a libvorbis -color_primaries 1 -color_trc 1 -colorspace 1 -crf 30 -g 120 -minrate 1.5M -b:v 1500 -g 120 -maxrate 1.5M -cluster_time_limit 5100 -shortest sorry.webm + +ffmpeg -y -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -loop 1 -r 20 -t 10 -i sorry.png -vf scale=854:480 -c:v libvpx -c:a libvorbis -color_primaries 1 -color_trc 1 -colorspace 1 -crf 30 -g 120 -minrate 1.5M -b:v 1500 -g 120 -maxrate 1.5M -cluster_time_limit 5100 -shortest sorry-480p.webm + * OBS ansible-playbook -i inventory.yml prod-playbook.yml --tags obs @@ -201,11 +206,9 @@ Firefox profiles like to be created in an X environment firefox -no-remote -CreateProfile "{{ emacsconf_id }}-{{ item.item.id }} Update scenes from the gen copy: -ssh emacsconf-gen@res.emacsconf.org -p 46668 "cat ~/.config/obs-studio/basic/scenes/gen.json" | jq 'walk(if type == "string" then gsub("emacsconf"; "{{ emacsconf_id }}") | gsub("gen"; "{{ item.id }}") else . end)' > roles/obs/templates/scenes.json +ssh emacsconf-gen@res.emacsconf.org -p 46668 "cat ~/.config/obs-studio/basic/scenes/emacsconf.json" | jq 'walk(if type == "string" then gsub("emacsconf"; "{{ emacsconf_id }}") else . end)' > roles/obs/templates/scenes.json 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 diff --git a/roles/stream/files/sorry-480p.webm b/roles/stream/files/sorry-480p.webm new file mode 100644 index 0000000..0bd0a6b Binary files /dev/null and b/roles/stream/files/sorry-480p.webm differ diff --git a/roles/stream/files/sorry.png b/roles/stream/files/sorry.png new file mode 100644 index 0000000..6e066af Binary files /dev/null and b/roles/stream/files/sorry.png differ diff --git a/roles/stream/files/sorry.svg b/roles/stream/files/sorry.svg new file mode 100644 index 0000000..d9951d9 --- /dev/null +++ b/roles/stream/files/sorry.svg @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SORRY + Something's wrong with the stream.Please try refreshing your browser or media playerin a minute or two.You can also check the#emacsconf-org IRC channel on the irc.libera.chat networkor https://status.emacsconf.org .Thank you for your patience! + + + + diff --git a/roles/stream/files/sorry.webm b/roles/stream/files/sorry.webm new file mode 100644 index 0000000..12e1661 Binary files /dev/null and b/roles/stream/files/sorry.webm differ diff --git a/roles/stream/tasks/main.yml b/roles/stream/tasks/main.yml index 9c35f69..6a53df1 100644 --- a/roles/stream/tasks/main.yml +++ b/roles/stream/tasks/main.yml @@ -63,7 +63,7 @@ tags: restream template: src: restream.sh - dest: /home/orga/restream-{{ item[1].name }}-{{ item[0].name }}.sh + dest: /usr/local/bin/restream-{{ item[1].name }}-{{ item[0].name }} owner: orga mode: 0755 loop: "{{ restreaming_platforms | subelements('streams') | list }}" @@ -72,8 +72,30 @@ tags: restream template: src: screen-restream.sh - dest: /home/orga/screen-restream-{{ item[1].name }}-{{ item[0].name }}.sh + dest: /usr/local/bin/screen-restream-{{ item[1].name }}-{{ item[0].name }}.sh owner: orga mode: 0755 loop: "{{ restreaming_platforms | subelements('streams') | list }}" no_log: True +- name: Copy fallback files + copy: + src: sorry.webm + dest: /usr/share/icecast2/web/fallback.webm + mode: 0644 + owner: "{{ icecast_user }}" + group: "{{ icecast_group }}" +- name: Copy 480p fallback files + copy: + src: sorry-480p.webm + dest: /usr/share/icecast2/web/480p-fallback.webm + mode: 0644 + owner: "{{ icecast_user }}" + group: "{{ icecast_group }}" +- name: Make a script to kick off all the fallbacks + template: + src: screen-fallbacks + dest: /usr/local/bin/screen-fallbacks + mode: 0755 + owner: "{{ icecast_user }}" + group: "{{ icecast_group }}" + diff --git a/roles/stream/tasks/track.yml b/roles/stream/tasks/track.yml index d1e8204..3afb712 100644 --- a/roles/stream/tasks/track.yml +++ b/roles/stream/tasks/track.yml @@ -13,5 +13,23 @@ src: on-disconnect dest: /usr/local/bin/{{ emacsconf_id }}-lowres-{{ item.id }}-on-disconnect mode: 0755 - - +- name: Copy fallback script + template: + src: screen-fallback.sh + dest: /usr/local/bin/screen-fallback-{{ item.id }} + mode: 0755 + owner: "{{ icecast_user }}" + group: "{{ icecast_group }}" + vars: + filename: fallback.webm + mount: "{{ item.id }}-sorry.webm" +- name: Copy 480p fallback script + template: + src: screen-fallback.sh + dest: /usr/local/bin/screen-fallback-{{ item.id }}-480p + mode: 0755 + owner: "{{ icecast_user }}" + group: "{{ icecast_group }}" + vars: + filename: 480p-fallback.webm + mount: "{{ item.id }}-480p-sorry.webm" 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