Entrar
PT
games/satisfying-bounce / tools / make-videos.sh · commit 8bdd6e4
#!/bin/bash# The films of Satisfying Bounce: every template in English and in French, in parallel, then the light versions for the site.#   games/satisfying-bounce/tools/make-videos.sh [template...]        (from anywhere inside the project)# -> games/satisfying-bounce/dist/video/satisfying-bounce-<template>-<seed>-<lang>.mp4 (1080 x 1920, 60 FPS)#    games/satisfying-bounce/site/videos/<template>-<lang>.mp4 (540 x 960, 30 FPS, light) + site/images/<template>-<lang>.jpg (poster)set -euo pipefailROOT="$(cd "$(dirname "$0")/../../.." && pwd)"GAME="games/satisfying-bounce"SEED=3declare -A SECONDS_OF=([gap]=26 [multiply]=22 [rings]=24 [marble]=24 [zoom]=28 [stairs]=24 [tunnel]=24 [spiral]=24 [checker]=24 [ripple]=24 [dominos]=24 [cats]=24 [rain]=24 [pendulum]=24 [plinko]=24)TEMPLATES=("$@")[ ${#TEMPLATES[@]} -gt 0 ] || TEMPLATES=(gap multiply rings marble zoom stairs tunnel spiral checker ripple dominos cats rain pendulum plinko)JOBS="${JOBS:-8}"cd "$ROOT"mkdir -p "$GAME/site/videos" "$GAME/site/images"for t in "${TEMPLATES[@]}"; do for l in en fr; do echo "$t $l ${SECONDS_OF[$t]}"; done; done |  xargs -P "$JOBS" -L 1 bash -c 'for try in 1 2 3; do bin/jumphp video:make satisfying-bounce --template "$0" --lang "$1" --seconds "$2" --seed '"$SEED"' > "'"$GAME"'/var/video-$0-$1.log" 2>&1 && exit 0; sleep 20; done; echo "FAILED $0 $1"; tail -5 "'"$GAME"'/var/video-$0-$1.log"'ff() { docker run --rm -u "$(id -u):$(id -g)" -v "$ROOT/$GAME:/g" -w /g jumphp/ffmpeg:dev -hide_banner -loglevel error -y "$@"; }for t in "${TEMPLATES[@]}"; do for l in en fr; do  src="dist/video/satisfying-bounce-$t-$SEED-$l.mp4"  [ -f "$ROOT/$GAME/$src" ] || { echo "missing $src"; continue; }  ff -i "$src" -vf "scale=540:960:flags=lanczos,fps=30,format=yuv420p" -c:v libx264 -preset slow -crf 27 -maxrate 2200k -bufsize 4400k -c:a aac -b:a 96k -movflags +faststart "site/videos/$t-$l.mp4"  ff -ss 2.5 -i "$src" -frames:v 1 -vf "scale=540:960:flags=lanczos" -q:v 4 "site/images/$t-$l.jpg"done; donels -la "$ROOT/$GAME/site/videos"