summaryrefslogtreecommitdiffstats
path: root/roles/prerec
diff options
context:
space:
mode:
Diffstat (limited to 'roles/prerec')
-rw-r--r--roles/prerec/tasks/main.yml3
-rw-r--r--roles/prerec/templates/Makefile55
-rwxr-xr-xroles/prerec/templates/copy-original.sh24
-rwxr-xr-xroles/prerec/templates/get-file-prefix10
-rwxr-xr-xroles/prerec/templates/reencode-in-screen.sh16
-rwxr-xr-xroles/prerec/templates/upload.sh4
6 files changed, 106 insertions, 6 deletions
diff --git a/roles/prerec/tasks/main.yml b/roles/prerec/tasks/main.yml
index 5b39977..a0a3cac 100644
--- a/roles/prerec/tasks/main.yml
+++ b/roles/prerec/tasks/main.yml
@@ -68,10 +68,11 @@
- verify-main.sh
- remux.sh
- get-file-prefix
+ - reencode-in-screen.sh
- name: Copy Makefile
+ tags: process-prerec, prerec-scripts, prerec-make
template:
src: Makefile
dest: "{{ emacsconf_caption_dir }}/cache/Makefile"
owner: "{{ emacsconf_user }}"
group: "{{ emacsconf_group }}"
-
diff --git a/roles/prerec/templates/Makefile b/roles/prerec/templates/Makefile
index 709a069..8579965 100644
--- a/roles/prerec/templates/Makefile
+++ b/roles/prerec/templates/Makefile
@@ -1,5 +1,7 @@
# {{ ansible_managed }}
+# To recreate this file, use ansible-playbook -i inventory.yml prod-playbook.yml --tags prerec-make
+
VIDEO_EXTS = mp4 mkv webm mov
source_patterns = $(foreach ext,$(VIDEO_EXTS),$(1)--original.$(ext))
@@ -11,6 +13,7 @@ PRERECS_NORMAL := $(addsuffix --normalized.opus, $(PREFIXES))
PRERECS_MAIN := $(addsuffix --main.webm, $(PREFIXES))
PRERECS_CAPTIONS := $(addsuffix --reencoded.vtt, $(PREFIXES))
PRERECS_FINAL := $(wildcard emacsconf-*--final.webm)
+LINODE_BBB_ID := 67329098
.PHONY: all
@@ -38,10 +41,13 @@ emacsconf-%--reencoded.webm:
./reencode-in-screen.sh "$(SOURCE)"
emacsconf-%--reencoded.opus: emacsconf-%--reencoded.webm
- ffmpeg -i "$<" -c:a copy "$@"
+ ffmpeg -y -i "$<" -c:a copy "$@"
+
+emacsconf-%--answers.opus: emacsconf-%--answers.webm
+ ffmpeg -y -i "$<" -c:a copy "$@"
-emacsconf-%--normalized.opus: emacsconf-%--reencoded.opus
- ffmpeg-normalize "$<" -ofmt opus -c:a libopus -o "$@"
+# emacsconf-%--normalized.opus: emacsconf-%--reencoded.opus
+# ffmpeg-normalize "$<" -ofmt opus -c:a libopus -o "$@"
emacsconf-%--main.webm: emacsconf-%--reencoded.webm emacsconf-%--normalized.opus emacsconf-%--main.vtt
ffmpeg -i emacsconf-$*--reencoded.webm -i emacsconf-$*--normalized.opus -i emacsconf-$*--main.vtt \
@@ -49,15 +55,26 @@ emacsconf-%--main.webm: emacsconf-%--reencoded.webm emacsconf-%--normalized.opus
-map 2 -c:s webvtt -y \
$@
+emacsconf-%--main.webm: emacsconf-%--reencoded.webm emacsconf-%--normalized.opus
+ ffmpeg -i emacsconf-$*--reencoded.webm -i emacsconf-$*--normalized.opus \
+ -map 0:v -map 1:a -c:v copy -c:a copy \
+ -y $@
+
emacsconf-%--main.webm: emacsconf-%--reencoded.webm
cp "$<" "$@"
emacsconf-%--final.webm: emacsconf-%--main.vtt
mux-subs.sh "$@" "$<"
+emacsconf-%--main.opus: emacsconf-%--main.webm
+ ffmpeg -y -i "$<" -c:a copy "$@"
+
emacsconf-%--reencoded.vtt: emacsconf-%--reencoded.opus
whisperx --model large-v2 --align_model WAV2VEC2_ASR_LARGE_LV60K_960H --compute_type int8 --print_progress True --max_line_width 50 --segment_resolution chunk --max_line_count 1 --language en "$<"
+emacsconf-%--backstage--silences.csv: emacsconf-%--reencoded.opus
+ ffmpeg -i "$<" -af silencedetect=noise=-30dB:d=0.5 -f null - 2>&1 | awk '/silence_start/ {start=$$NF} /silence_end/ {print start "," (start + $$NF)}' > "$@"
+
show-files:
@echo "Original $(words $(PRERECS_ORIGINAL)):"
@echo "$(PRERECS_ORIGINAL)"
@@ -68,5 +85,37 @@ show-files:
@echo "Opus $(words $(PRERECS_OPUS)):"
@echo "$(PRERECS_OPUS)"
+bbb-testing:
+ @echo "Resizing BBB node to 8GB 4 core for testing"
+ linode-cli linodes resize $(LINODE_BBB_ID) --type g6-standard-4 --allow_auto_disk_resize false
+ sleep 2m
+ @echo "Booting up"
+ linode-cli linodes boot $(LINODE_BBB_ID)
+ ssh root@bbb.emacsverse.org "cd ~/greenlight-v3; docker compose restart"
+
+bbb-dormant:
+ @echo "Shutting down"
+ ssh root@bbb.emacsverse.org "/usr/sbin/shutdown -h now &" || true
+ sleep 30
+ @echo "Powering off BBB node"
+ linode-cli linodes shutdown $(LINODE_BBB_ID)
+ sleep 30
+ @echo "Resizing BBB node to nanode, dormant"
+ linode-cli linodes resize $(LINODE_BBB_ID) --type g6-nanode-1 --allow_auto_disk_resize false
+
+bbb-prod:
+ @echo "Resizing BBB node to production size"
+ linode-cli linodes resize $(LINODE_BBB_ID) --type g6-dedicated-8 --allow_auto_disk_resize true
+ sleep 2m
+ @echo "Booting up"
+ linode-cli linodes boot $(LINODE_BBB_ID)
+
+live-dormant:
+ @echo "Resizing live0 node to nanode, dormant"
+ linode-cli linodes resize 17921960 --type g6-nanode-1 --allow_auto_disk_resize false
+ sleep 120
+ linode-cli linodes boot 17921960
+
+
rsync:
rsync -avzue ssh {{ emacsconf_caption_dir }}/cache/ orga@media.emacsconf.org:/var/www/media.emacsconf.org/{{ emacsconf_year }}/backstage/
diff --git a/roles/prerec/templates/copy-original.sh b/roles/prerec/templates/copy-original.sh
new file mode 100755
index 0000000..854bdb8
--- /dev/null
+++ b/roles/prerec/templates/copy-original.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# {{ ansible_managed }}
+# Usage: rename-original.sh $slug $file [$extra]
+SLUG=$1
+FILE=$2
+EXTRA=""
+if [ -z ${3-unset} ]; then
+ EXTRA=""
+elif [ -n "$3" ]; then
+ EXTRA="$3"
+elif echo "$FILE" | grep -e '\(webm\|mp4\|mov\)'; then
+ EXTRA="--original"
+fi
+filename=$(basename -- "$FILE")
+extension="${filename##*.}"
+filename="${filename%.*}"
+FILE_PREFIX=$(get-file-prefix $SLUG)
+if echo "$FILE" | grep -q \\. ; then
+ cp "$FILE" $FILE_PREFIX$EXTRA.$extension
+ echo $FILE_PREFIX$EXTRA.$extension
+else
+ cp "$FILE" $FILE_PREFIX$EXTRA
+ echo $FILE_PREFIX$EXTRA
+fi
diff --git a/roles/prerec/templates/get-file-prefix b/roles/prerec/templates/get-file-prefix
new file mode 100755
index 0000000..0240b99
--- /dev/null
+++ b/roles/prerec/templates/get-file-prefix
@@ -0,0 +1,10 @@
+#!/bin/bash
+# {{ ansible_managed }}
+# Usage: get-file-prefix $slug [talks.json]
+# You can also set the TALKS_JSON environment variable
+
+SLUG=$1
+if [ -z "$TALKS_JSON" ]; then
+ TALKS_JSON=${2:-~orga/current/talks.json}
+fi
+jq -r '.talks[] | select(.slug=="'$SLUG'")["file-prefix"]' < $TALKS_JSON
diff --git a/roles/prerec/templates/reencode-in-screen.sh b/roles/prerec/templates/reencode-in-screen.sh
new file mode 100755
index 0000000..5c12203
--- /dev/null
+++ b/roles/prerec/templates/reencode-in-screen.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+ORIGINAL=$1
+BASE="${ORIGINAL%--original.*}"
+REENCODED="${BASE}--reencoded.webm"
+SLUG=$(echo "$ORIGINAL" | perl -ne '/^emacsconf-[0-9]*-(.*?)--/ && print $1')
+LOCK=".lock-$SLUG"
+
+if [ ! -f "$REENCODED" ]; then
+ if [ -f "$LOCK" ]; then
+ echo "$LOCK already exists, waiting for it"
+ else
+ touch "$LOCK"
+ screen -dmS reencode-$SLUG /bin/bash -c "reencode.sh \"$ORIGINAL\" \"$REENCODED\" && thumbnail.sh \"$MAIN\" && rm \"$LOCK\""
+ echo "Processing $REENCODED in reencode-$SLUG"
+ fi
+fi
diff --git a/roles/prerec/templates/upload.sh b/roles/prerec/templates/upload.sh
index fbf3025..09d55d9 100755
--- a/roles/prerec/templates/upload.sh
+++ b/roles/prerec/templates/upload.sh
@@ -2,5 +2,5 @@
# {{ ansible_managed }}
scp $* orga@media.emacsconf.org:~/backstage
-/data/emacsconf/admin/{{ emacsconf_year }}/scripts/publish-backstage-index.sh
-rsync -avze ssh orga@media.emacsconf.org:~/backstage/ /data/emacsconf/admin/cache/
+/usr/local/bin/publish-backstage-index.sh
+rsync -avze ssh orga@media.emacsconf.org:~/backstage/ /data/emacsconf/shared/{{ emacsconf_year }}/cache/