#!/bin/bash # SPDX-License-Identifier: BSD-3-Clause # frame_sequence.sh - capture an animated GPU-rendered frame sequence end to # end: run the guest's CUDA frame producer into the kvmfr ivshmem BAR and # save every published frame on the host as PPM/PNG (the proven # CUDA -> ivshmem -> host path; see docs/05-operations/06). # # Usage: tools/lg/frame_sequence.sh [frames] [width] [height] [fps] [outdir] set -u HERE="$(cd "$(dirname "$0")" && pwd)" REPO="$(cd "$HERE/../.." && pwd)" FRAMES="${1:-40}" W="${2:-800}" H="${3:-600}" FPS="${4:-10}" OUT="${5:-/tmp/opencode/frames-seq}" mkdir -p "$OUT" rm -f "$OUT"/frame-*.ppm "$OUT"/frame-*.png # Start the host reader first so no published frame is missed. python3 "$REPO/tools/lg/frame_reader.py" --frames "$FRAMES" --out "$OUT" \ --timeout 240 > "$OUT/reader.log" 2>&1 & READER=$! sleep 1 "$REPO/scripts/ssh_guest.sh" \ "sudo /tmp/frame_producer $FRAMES $W $H $FPS" 2>&1 | grep -v "Permanently added" \ | tail -5 wait "$READER" echo "reader rc=$?" ls -1 "$OUT"/frame-*.ppm 2>/dev/null | wc -l