summaryrefslogblamecommitdiffstats
path: root/roles/prerec/templates/Makefile
blob: 85799651136fec89a507923396a227b0447b5379 (plain) (tree)
1
2
3
4

                       

                                                                                                   










                                                                                     
                         

           
 
                               






















                                                                            



                                                    
 

                                                             






                                                                                                           




                                                                                 
                                                   

                    
                                              
                             
 


                                              
                                                       
                                                                                                                                                                                                            
 


                                                                                                                                                                    









                                                        

                                                           
                                                                                                      

                          
                                                






                                                                                
                                                    

                                                    
                                                                                                    


                                                    
                                                                                                      

                          
                                                







                                                                                            

                                                                                                                                                 
# {{ 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))

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)
LINODE_BBB_ID := 67329098

.PHONY: all

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 -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-%--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 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)"
	@echo "Prefixes $(words $(PREFIXES)):"
	@echo "$(PREFIXES)"
	@echo "Reencoded $(words $(PRERECS_REENCODED)):"
	@echo "$(PRERECS_REENCODED)"
	@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/