The demo tooling only existed in a session scratch directory, which is
temporary. This puts it in the repo so the video can be rebuilt.
Terminal only: tmux drives a two pane session, asciinema records it, agg
renders it, ffmpeg encodes it. The left pane runs the loop against a live
ZVM, the right pane polls the VPG journal so the tagged checkpoint appears
on camera as it lands.
Narration is synthesised per beat and aligned to marks the driver writes
while it runs, rather than to predicted timings, so a slow API call or an
FLR mount that takes longer than usual does not drift the audio. Two
things that has to respect are written down in the README: agg's
idle-time-limit must exceed the longest pause or it compresses idle time
and breaks the wall-clock mapping, and each beat holds for its narration
length so no line is cut off.
demo_win.json carries live guest credentials, so only an example with
placeholders is committed and the real file is gitignored, along with the
generated wav, cast, gif and mp4.
The xAI key path and voice id come from the environment now instead of
being hardcoded to one machine.
Also records the narration gotchas that cost time: mapping an acronym to
run-together phonetics ({"VM": "vee em"}) is spoken as one word, "vem";
prose written for the page sounds robotic read aloud; and volumedetect
reports no samples when aimed at a file whose first stream is video,
which makes a working audio track look silent.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016yVfC5nvZowoLFnEGWhLGn
43 lines
1.9 KiB
Bash
Executable File
43 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Record the Windows rewind demo. NO idle compression: the video timeline must
|
|
# equal wall clock so the narration can be aligned to the recorded beat marks.
|
|
set -uo pipefail
|
|
SP="$(cd "$(dirname "$0")" && pwd)"
|
|
REPO=/home/justin/github/zerto-ai-rewind
|
|
PY="$REPO/.venv/bin/python"
|
|
VPG_ID=$(python3 -c "import json;print(json.load(open('$SP/demo_win.json'))['vpg_id'])")
|
|
TAKE="${1:-win1}"
|
|
CAST="$SP/$TAKE.cast"; GIF="$SP/$TAKE.gif"; MP4="$SP/$TAKE.mp4"
|
|
|
|
tmux -L demo kill-server 2>/dev/null; tmux -L rec kill-server 2>/dev/null; sleep 1
|
|
rm -f "$SP/marks.jsonl"
|
|
|
|
tmux -L demo new-session -d -s demo -x 200 -y 50 -c "$REPO" \
|
|
"$PY $SP/windows_driver.py; echo; echo ' [take complete]'; sleep 2; tmux -L demo kill-server"
|
|
tmux -L demo set-option -g status off
|
|
tmux -L demo split-window -h -l 60 -t demo -c "$REPO" \
|
|
"JOURNAL_ROWS=10 $PY $SP/journal.py $VPG_ID ad1"
|
|
tmux -L demo select-pane -t 0
|
|
|
|
tmux -L rec new-session -d -s rec -x 200 -y 50 \
|
|
"$SP/recvenv/bin/asciinema rec '$CAST' --overwrite --quiet -c 'tmux -L demo attach -t demo'"
|
|
|
|
echo "recording -> $CAST"
|
|
for i in $(seq 1 450); do tmux -L rec has-session -t rec 2>/dev/null || break; sleep 2; done
|
|
tmux -L demo kill-server 2>/dev/null; tmux -L rec kill-server 2>/dev/null; sleep 1
|
|
[ -s "$CAST" ] || { echo "NO CAST"; exit 1; }
|
|
|
|
echo "cast duration: $(python3 -c "
|
|
import json
|
|
last=0
|
|
for l in open('$CAST'):
|
|
l=l.strip()
|
|
if l.startswith('['): last=json.loads(l)[0]
|
|
print(f'{last:.1f}s')")"
|
|
# idle-time-limit huge = no compression, so 1s of cast == 1s of video
|
|
"$SP/bin/agg" --font-size 14 --fps-cap 10 --idle-time-limit 3600 --theme asciinema "$CAST" "$GIF"
|
|
ffmpeg -y -loglevel error -i "$GIF" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 \
|
|
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" "$MP4"
|
|
echo "MP4: $MP4 ($(du -h "$MP4" | cut -f1))"
|
|
ffprobe -v error -show_entries format=duration:stream=width,height -of default=nw=1 "$MP4"
|