singe/util/demoRecord.sh
2026-10-05 22:12:53 -05:00

24 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# Records one of the demos, start to finish, to an MP4 with its music, using Singe's own recorder:
#
# util/demoRecord.sh neonCoast screenshots/demos/neonCoast.mp4
#
# The demos folder is copied to a scratch folder and run from there headless with --deterministic
# and --record, so every frame is kept and the sound is mixed in step with the picture. Nothing
# appears on screen and nothing is heard. SCRATCH defaults to a folder under /tmp. For stretches
# of a demo as pictures to look at, see util/demoCapture.sh.
set -euo pipefail
DEMO=$1
OUT=$(realpath -m "$2")
STEP=20
REPO=$(cd "$(dirname "$0")/.." && pwd)
BIN=$(ls "$REPO"/.builddir/Singe-v*-Linux-x86_64 | head -1)
SCRATCH=${SCRATCH:-/tmp/demoRecord-$DEMO}
rm -rf "$SCRATCH"
mkdir -p "$SCRATCH/run"
cp -r "$REPO/demos/." "$SCRATCH/run/"
cd "$SCRATCH/run"
SDL_VIDEODRIVER=offscreen SDL_AUDIO_DRIVER=dummy timeout -k 10 7200 "$BIN" -k -w -C 640x480 -x 1024 -y 768 --deterministic=$STEP --record="$OUT" -p -d "$SCRATCH/data" "$DEMO/$DEMO.singe" > "$SCRATCH/run.log" 2>&1 || true
grep -E "Recording|Recorded|rror" "$SCRATCH/run.log" || true