summaryrefslogtreecommitdiffstats
path: root/roles/prerec/templates/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'roles/prerec/templates/Makefile')
-rw-r--r--roles/prerec/templates/Makefile66
1 files changed, 61 insertions, 5 deletions
diff --git a/roles/prerec/templates/Makefile b/roles/prerec/templates/Makefile
index 94aa412..709a069 100644
--- a/roles/prerec/templates/Makefile
+++ b/roles/prerec/templates/Makefile
@@ -1,16 +1,72 @@
# {{ ansible_managed }}
-PRERECS_FINAL := $(wildcard {{ emacsconf_id }}-*--final.webm)
-PRERECS_MAIN := $(patsubst %--final.webm, %--main.webm, $(PRERECS_FINAL))
+VIDEO_EXTS = mp4 mkv webm mov
+source_patterns = $(foreach ext,$(VIDEO_EXTS),$(1)--original.$(ext))
+
+PRERECS_ORIGINAL := $(wildcard emacsconf-*--original.*)
+PREFIXES := $(shell for f in $(PRERECS_ORIGINAL); do echo "$${f%--original.*}"; done)
+PRERECS_REENCODED := $(addsuffix --reencoded.webm, $(PREFIXES))
+PRERECS_OPUS := $(addsuffix --reencoded.opus, $(PREFIXES))
+PRERECS_NORMAL := $(addsuffix --normalized.opus, $(PREFIXES))
+PRERECS_MAIN := $(addsuffix --main.webm, $(PREFIXES))
+PRERECS_CAPTIONS := $(addsuffix --reencoded.vtt, $(PREFIXES))
+PRERECS_FINAL := $(wildcard emacsconf-*--final.webm)
.PHONY: all
-all: $(PRERECS_MAIN) $(PRERECS_FINAL)
-emacsconf-%--main.webm: {{ emacsconf_id }}-%--final.webm
+all: reencoded opus normal main
+
+reencoded: $(PRERECS_REENCODED)
+
+opus: $(PRERECS_OPUS)
+
+normal: $(PRERECS_NORMAL)
+
+captions: $(PRERECS_CAPTIONS)
+
+main: $(PRERECS_MAIN)
+
+emacsconf-%--reencoded.webm: SOURCES = $(call source_patterns, emacsconf-$*)
+emacsconf-%--reencoded.webm:
+ $(eval SOURCE := $(lastword $(sort $(wildcard $(SOURCES)))))
+ @if [ -z "$(SOURCE)" ]; then \
+ echo "No source file found for $@"; \
+ echo "Tried: $(SOURCES)"; \
+ exit 1; \
+ fi
+ @echo "Using source: $(SOURCE)"
+ ./reencode-in-screen.sh "$(SOURCE)"
+
+emacsconf-%--reencoded.opus: emacsconf-%--reencoded.webm
+ ffmpeg -i "$<" -c:a copy "$@"
+
+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 \
+ -map 0:v -map 1:a -c:v copy -c:a copy \
+ -map 2 -c:s webvtt -y \
+ $@
+
+emacsconf-%--main.webm: emacsconf-%--reencoded.webm
cp "$<" "$@"
-emacsconf-%--final.webm: {{ emacsconf_id }}-%--main.vtt
+emacsconf-%--final.webm: emacsconf-%--main.vtt
mux-subs.sh "$@" "$<"
+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 "$<"
+
+show-files:
+ @echo "Original $(words $(PRERECS_ORIGINAL)):"
+ @echo "$(PRERECS_ORIGINAL)"
+ @echo "Prefixes $(words $(PREFIXES)):"
+ @echo "$(PREFIXES)"
+ @echo "Reencoded $(words $(PRERECS_REENCODED)):"
+ @echo "$(PRERECS_REENCODED)"
+ @echo "Opus $(words $(PRERECS_OPUS)):"
+ @echo "$(PRERECS_OPUS)"
+
rsync:
rsync -avzue ssh {{ emacsconf_caption_dir }}/cache/ orga@media.emacsconf.org:/var/www/media.emacsconf.org/{{ emacsconf_year }}/backstage/