#!/usr/bin/env bash # Build the WaveWarZ clip: a title card, then the edited battle moment with # burned-in captions and an @wavewarz tag. # # All CUES/KEEP times live in clip.wav coordinates, which start SRC_OFF seconds # into the downloaded window. Nothing else in the pipeline knows about that # offset, so it is applied here once. set -euo pipefail cd "$(dirname "$0")" SRC=vid_v2855698113_2560.mp4 SRC_OFF=17.5 FONT=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf GREEN=0x69FF81 # sampled off the stream's own background W=720; H=1280; FPS=30 # KEEP, shifted into source coordinates A_IN=$(python3 -c "print(17.5+0.00)"); A_OUT=$(python3 -c "print(17.5+23.52)") B_IN=$(python3 -c "print(17.5+34.92)"); B_OUT=$(python3 -c "print(17.5+62.40)") python3 make_srt.py clip.srt # ---- title card ----------------------------------------------------------- card() { local y=$1 size=$2 color=$3 text=$4 echo "drawtext=fontfile=${FONT}:text='${text}':fontcolor=${color}:fontsize=${size}:x=(w-text_w)/2:y=${y}" } FILT_CARD="$(card 300 74 ${GREEN} 'WAVEWARZ'),\ $(card 392 30 0xBBBBBB 'SONG VS. SONG · AUG 25'),\ $(card 560 44 0xFFFFFF 'Hypnotic'),\ $(card 626 30 0x888888 'vs'),\ $(card 682 44 0xFFFFFF 'Dolphin Flippin'),\ $(card 748 28 0x888888 'both by geekmyth'),\ $(card 900 30 0xBBBBBB '0.111 SOL IN PLAY'),\ $(card 946 52 ${GREEN} 'DECIDED BY 0.001'),\ $(card 1150 26 0x888888 '@wavewarz')" ffmpeg -v error -y \ -f lavfi -i "color=c=black:s=${W}x${H}:r=${FPS}:d=4" \ -f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=44100:d=4" \ -vf "${FILT_CARD}" \ -c:v libx264 -preset veryfast -crf 20 -pix_fmt yuv420p -profile:v high -level 4.0 \ -c:a aac -b:a 128k -ar 44100 -ac 2 -shortest card.mp4 # ---- body ----------------------------------------------------------------- # force_style sizes are in the subtitle script's own coordinate space, and an # SRT has no header so libass falls back to PlayResY=288 — not the 1280 of the # video. Everything here is therefore written as (pixels * 288 / 1280). STYLE="FontName=DejaVu Sans,Fontsize=10,Bold=1,PrimaryColour=&H00FFFFFF,\ OutlineColour=&H00000000,BorderStyle=1,Outline=1,Shadow=0,Alignment=2,MarginV=30" ffmpeg -v error -y -i "${SRC}" -filter_complex "\ [0:v]trim=${A_IN}:${A_OUT},setpts=PTS-STARTPTS[v0];\ [0:a]atrim=${A_IN}:${A_OUT},asetpts=PTS-STARTPTS,afade=t=out:st=23.22:d=0.3[a0];\ [0:v]trim=${B_IN}:${B_OUT},setpts=PTS-STARTPTS[v1];\ [0:a]atrim=${B_IN}:${B_OUT},asetpts=PTS-STARTPTS,afade=t=in:st=0:d=0.3[a1];\ [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a];\ [v]subtitles=clip.srt:force_style='${STYLE}'[vs];\ [vs]drawtext=fontfile=${FONT}:text='@wavewarz':fontcolor=white@0.85:fontsize=28:\ box=1:boxcolor=black@0.45:boxborderw=10:x=w-text_w-26:y=26[vout]" \ -map "[vout]" -map "[a]" \ -c:v libx264 -preset veryfast -crf 20 -pix_fmt yuv420p -profile:v high -level 4.0 \ -r ${FPS} -c:a aac -b:a 128k -ar 44100 -ac 2 body.mp4 # ---- join ----------------------------------------------------------------- printf "file '%s'\nfile '%s'\n" "$PWD/card.mp4" "$PWD/body.mp4" > concat.txt ffmpeg -v error -y -f concat -safe 0 -i concat.txt -c copy wavewarz-flippening.mp4 ffprobe -v error -show_entries format=duration,size -show_entries stream=width,height,codec_name \ -of default=nw=1 wavewarz-flippening.mp4