feat(tools): pace recordings by the shell prompt
This commit is contained in:
3 files changed
+32
-8
No files matched your search
+24
-1
@@ -5,6 +5,7 @@ set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
FONT=${FONT:-JetBrainsMono Nerd Font Mono}
|
||||
FPS=${FPS:-12}
|
||||
DELAY=${DELAY:-42}
|
||||
|
||||
start_xvfb() {
|
||||
local geometry=$1
|
||||
@@ -41,12 +42,34 @@ stop_capture() {
|
||||
|
||||
send_line() {
|
||||
local text=$1 pause=${2:-0.9}
|
||||
xdotool type --delay 42 -- "$text"
|
||||
xdotool type --delay "$DELAY" -- "$text"
|
||||
sleep 0.35
|
||||
xdotool key Return
|
||||
sleep "$pause"
|
||||
}
|
||||
|
||||
# Fixed sleeps race a build that takes longer than expected, and the keystrokes
|
||||
# land in the middle of its output. PROMPT_COMMAND appends a byte every time the
|
||||
# shell draws a prompt, so the recorder can wait for the command to actually end.
|
||||
wait_prompt() {
|
||||
local before=$1 limit=${2:-600}
|
||||
for _ in $(seq "$limit"); do
|
||||
[ "$(wc -c <"$PROMPT_FILE" 2>/dev/null || echo 0)" != "$before" ] && return 0
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
run_line() {
|
||||
local text=$1 settle=${2:-0.8}
|
||||
local before
|
||||
before=$(wc -c <"$PROMPT_FILE" 2>/dev/null || echo 0)
|
||||
xdotool type --delay "$DELAY" -- "$text"
|
||||
sleep 0.35
|
||||
xdotool key Return
|
||||
wait_prompt "$before"
|
||||
sleep "$settle"
|
||||
}
|
||||
|
||||
to_gif() {
|
||||
local src=$1 out=$2 fps=${3:-11}
|
||||
local palette=${src%.mkv}.png
|
||||
|
||||
@@ -5,6 +5,7 @@ GEOMETRY=${GEOMETRY:-1280x720}
|
||||
LUA=${LUA:-$HOME/projects/lua}
|
||||
OUT="$ROOT/assets/showcase.mp4"
|
||||
WORK=$(mktemp -d)
|
||||
PROMPT_FILE="$WORK/prompt"
|
||||
|
||||
cp -a "$LUA" "$WORK/lua"
|
||||
rm -rf "$WORK/lua/build"
|
||||
@@ -28,22 +29,22 @@ for _ in $(seq 30); do
|
||||
sleep 1
|
||||
done
|
||||
xdotool search --onlyvisible --class kitty windowactivate >/dev/null 2>&1 || true
|
||||
xdotool type --delay 10 -- 'export PS1="lua-5.4.7 $ " WINEDEBUG=-all LIBGL_ALWAYS_SOFTWARE=1 MESA_DEBUG=silent PATH='"$WORK"'/bin:$PATH; clear'
|
||||
xdotool type --delay 10 -- 'export PS1="lua-5.4.7 $ " PROMPT_COMMAND="printf . >> '"$PROMPT_FILE"'" PATH='"$WORK"'/bin:$PATH; clear'
|
||||
xdotool key Return
|
||||
sleep 1
|
||||
|
||||
start_capture "$GEOMETRY" "$WORK/showcase.mkv"
|
||||
|
||||
send_line 'meowc build' 8.5
|
||||
send_line './build/bin/lua -v' 1.8
|
||||
send_line 'meowc --target x86_64-w64-mingw32 build' 13
|
||||
send_line 'file build/x86_64-w64-mingw32/bin/lua.exe' 2.2
|
||||
send_line 'wine build/x86_64-w64-mingw32/bin/lua.exe -v' 3.2
|
||||
run_line 'meowc build' 1.6
|
||||
run_line 'touch src/*.c src/*.h' 0.6
|
||||
run_line 'meowc build' 1.8
|
||||
run_line 'echo "int lua_added_decl (lua_State *L);" >> src/lua.h' 0.6
|
||||
run_line 'meowc build' 2.5
|
||||
|
||||
stop_capture
|
||||
|
||||
# Fit the cut to the target length rather than truncating the ending off it
|
||||
LIMIT=${LIMIT:-29.5}
|
||||
LIMIT=${LIMIT:-45}
|
||||
raw=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$WORK/showcase.mkv")
|
||||
speed=$(python3 -c "print(max(1.0, $raw / $LIMIT))")
|
||||
ffmpeg -v error -y -i "$WORK/showcase.mkv" -an -vf "setpts=PTS/$speed" \
|
||||
|
||||
Reference in new issue
Block a user