demo: commit the recording harness (#8)
This commit was merged in pull request #8.
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
# Record the split-pane rewind demo to an MP4.
|
||||
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.json'))['vpg_id'])")"
|
||||
VPG_NAME="$(python3 -c "import json;print(json.load(open('$SP/demo.json'))['vpg_name'])")"
|
||||
TAKE="${1:-take1}"
|
||||
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
|
||||
|
||||
# demo session: driver left, journal right
|
||||
tmux -L demo new-session -d -s demo -x 200 -y 50 -c "$REPO" \
|
||||
"$PY $SP/driver.py; echo; echo ' [take complete]'; sleep 3; 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 $VPG_NAME"
|
||||
tmux -L demo select-pane -t 0
|
||||
|
||||
# recorder session gives asciinema a pty
|
||||
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 600); 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 PRODUCED"; exit 1; }
|
||||
echo "cast: $(du -h "$CAST" | cut -f1) duration: $(python3 -c "
|
||||
import json,sys
|
||||
last=0
|
||||
for l in open('$CAST'):
|
||||
l=l.strip()
|
||||
if l.startswith('['):
|
||||
last=json.loads(l)[0]
|
||||
print(f'{last:.0f}s')")"
|
||||
|
||||
"$SP/bin/agg" --font-size 14 --fps-cap 10 --idle-time-limit 2 --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"
|
||||
Reference in New Issue
Block a user