grip
grip: pass the whiteboard defense before you push. A quiz on your own diff.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/guilyx--grip)HTML
<a href="/listings/guilyx--grip"><img src="/api/listings/guilyx--grip/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
pipx install grip-hook # or: uv tool install grip-hook
Python 3.11 or newer, on Linux, macOS or Windows. This installs the `grip` command and a `git grip` alias.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 24 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- {
- "name": "grip",
- "owner": {
- "name": "Erwin L.",
- "url": "https://github.com/guilyx"
- },
- "description": "grip: pass the whiteboard defense before you push. A quiz on your own diff.",
- "plugins": [
- {
- "name": "grip",
- "source": "./",
- "description": "Quiz yourself on your diff before Claude pushes it. /grip asks five questions; a hook blocks `git push` until the diff has passed.",
- "version": "0.5.0",
- "author": {
- "name": "Erwin L."
- },
- "homepage": "https://guilyx.github.io/grip/agents/",
- "repository": "https://github.com/guilyx/grip",
- "license": "BSD-3-Clause",
- "category": "Development",
- "keywords": ["git", "hook", "quiz", "code-review", "understanding"]
- }
- ]
- }
README.md · README · 142 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- # grip
- **A git hook that won't let you push code you can't explain.**
- [](https://github.com/guilyx/grip/actions/workflows/ci.yml)
- [](https://pypi.org/project/grip-hook/)
- [](https://pypi.org/project/grip-hook/)
- [](https://guilyx.github.io/grip/)
- [](https://github.com/guilyx/grip/blob/main/LICENSE)
- 
- Before your code leaves your machine, grip reads the diff and asks you about it: why it is
- built this way, where it fails, what a malicious caller could do, how you know it works.
- In the terminal, or on a whiteboard of your change in the browser. A model grades your
- answers out of 100. Below your team's pass mark, the push waits.
- It checks the developer, not the code. Let AI write it; just be able to defend it.
- **[Follow one real change from commit to push](https://guilyx.github.io/grip/walkthrough/)**
- to see what it asks and how it grades.
- > "If I ask 'why did you do X instead of Y?', 'what happens if this actor behaves
- > maliciously?' [...] you should be able to answer confidently."
- > Mitchell Hashimoto, [on X](https://x.com/mitchellh/status/2100249348345057389), about
- > [the whiteboard defense](https://guilyx.github.io/grip/whiteboard-defense/) (not affiliated with grip)
- ## Try it in 30 seconds
- No hook, no account, no API key: the `fake` provider runs the whole flow offline.
- ```bash
- pipx install grip-hook # or: uv tool install grip-hook
- mkdir try-grip && cd try-grip && git init -q
- echo 'def add(a, b): return a + b' > math.py && git add math.py
- grip quiz --provider fake # five questions in your terminal
- grip whiteboard --provider fake # the same, drawn in your browser
- ```
- The offline grader does not read your answers, it only checks their length: twenty
- characters, or the word "because", gets full marks. Any long answer passes and a row of
- "idk" fails, so this shows the flow, not the grading. For questions written from your diff
- and real grading, use a model you have (`--provider claude-code`, `codex`, `gemini` or
- `anthropic`), or read the [walkthrough](https://guilyx.github.io/grip/walkthrough/).
- Nothing is blocked until you install the hook with `grip init`.
- ## Features
- - **Five questions from your diff**, graded against a hidden rubric into a Grip Score out
- of 100. Never line numbers or trivia.
- - **`grip whiteboard`**: your change drawn as parts and arrows in the browser, with the
- questions pinned to it, including what a malicious actor could do. Set
- `hook_mode = "whiteboard"` and every push is defended there.
- - **Works with what you have**: reuse Claude Code, Codex or Gemini CLI as the model (no
- API key), or use Anthropic, any OpenAI-compatible API, or Ollama locally.
- - **Inside coding agents**: `/grip` in Claude Code, Codex, Gemini CLI, Cursor and others,
- and a gate that keeps the agent from pushing until you pass.
- - **Out of the way when it should be**: a passed diff is remembered, a retry reuses its
- questions so only grading costs a call, `grip skip` lets one push through, CI and
- non-interactive runs are skipped.
- ## Installation
- ```bash
- pipx install grip-hook # or: uv tool install grip-hook
- ```
- Python 3.11 or newer, on Linux, macOS or Windows. This installs the `grip` command and a
- `git grip` alias.
- ## Quick start
- 
- ```bash
- cd your-repo
- grip init # writes .grip.toml, installs the pre-push hook
- git push # grip asks five questions first
- ```
- `grip init` writes `provider = "auto"`: each machine uses Claude Code, Codex or Gemini CLI
- when one is installed. Otherwise set `ANTHROPIC_API_KEY`, or see
- [Providers](https://guilyx.github.io/grip/providers/).
- Other commands you will use:
- ```bash
- grip quiz # quiz your staged changes now, no hook needed
- grip quiz --branch # quiz the whole branch since main: your pull request
- grip whiteboard # defend the change in the browser
- grip quiz --provider fake # try the flow offline (grades by length only)
- grip skip # let the next push through
- grip status # hooks, last score, configuration
- ```
- The [walkthrough](https://guilyx.github.io/grip/walkthrough/) follows one real change from
- `git commit` to an accepted push.
- ## Configuration
- `.grip.toml` at the root of the repository, committed so the team shares one bar:
- ```toml
- passing_score = 70 # 0-100
- difficulty = "normal" # easy | normal | hard
- provider = "claude-code" # auto | anthropic | claude-code | codex | gemini | openai | ollama
- ```
- Every option, environment variables and the pre-commit framework hook are in the
- [configuration reference](https://guilyx.github.io/grip/configuration/).
- ## Documentation
- **[guilyx.github.io/grip](https://guilyx.github.io/grip/)**: getting started, a
- walkthrough, coding agents, the whiteboard, how grip works inside, and the honest numbers
- on what the score does and does not measure.
- ## Contributing
- Issues and pull requests are welcome. See [CONTRIBUTING.md](https://github.com/guilyx/grip/blob/main/CONTRIBUTING.md)
- for the development setup and [SECURITY.md](https://github.com/guilyx/grip/blob/main/SECURITY.md)
- for reporting vulnerabilities and what data grip sends. This project follows a
- [code of conduct](https://github.com/guilyx/grip/blob/main/CODE_OF_CONDUCT.md).
- ## Citation
- If grip is part of a study or a course, please cite it; GitHub's "Cite this repository"
- button reads [CITATION.cff](https://github.com/guilyx/grip/blob/main/CITATION.cff).
- ## License
- [BSD-3-Clause](https://github.com/guilyx/grip/blob/main/LICENSE). Copyright (c) 2026, Erwin L.
- ## Star history
- <a href="https://star-history.com/#guilyx/grip&Date">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=guilyx/grip&type=Date&logscale&theme=dark" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=guilyx/grip&type=Date&logscale" />
- <img alt="Star history of guilyx/grip" src="https://api.star-history.com/svg?repos=guilyx/grip&type=Date&logscale" />
- </picture>
- </a>
install.sh · Bundled script · 73 lines · 1 finding marked
- #!/bin/sh
- # grip installer
- #
- # curl -fsSL https://raw.githubusercontent.com/guilyx/grip/main/install.sh | sh
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 4 on GitHub
- #
- # Installs grip from PyPI (the grip-hook package) as a command-line tool, with uv when it
- # is there and pipx otherwise. You get `grip` and a `git grip` alias. The same as running
- # `uv tool install grip-hook` or `pipx install grip-hook` yourself.
- #
- # Options (pass after `sh -s --` when piping):
- # --version X.Y.Z install a specific version (default: latest)
- # --uninstall remove grip
- # -h, --help show this help
- #
- # Environment overrides: GRIP_VERSION, GRIP_PACKAGE (a name, wheel path or URL).
- set -eu
- PACKAGE="${GRIP_PACKAGE:-grip-hook}"
- VERSION="${GRIP_VERSION:-}"
- UNINSTALL=0
- say() { printf '%s\n' "grip: $*"; }
- die() { printf '%s\n' "grip: error: $*" >&2; exit 1; }
- usage() {
- sed -n '2,15p' "$0" 2>/dev/null | sed 's/^# \{0,1\}//' || true
- }
- while [ $# -gt 0 ]; do
- case "$1" in
- --version) [ $# -ge 2 ] || die "--version needs a value"; VERSION="$2"; shift 2 ;;
- --version=*) VERSION="${1#*=}"; shift ;;
- --uninstall) UNINSTALL=1; shift ;;
- -h | --help) usage; exit 0 ;;
- *) die "unknown option: $1 (try --help)" ;;
- esac
- done
- VERSION="${VERSION#v}"
- spec="$PACKAGE"
- [ -n "$VERSION" ] && spec="$PACKAGE==$VERSION"
- if command -v uv >/dev/null 2>&1; then
- tool=uv
- elif command -v pipx >/dev/null 2>&1; then
- tool=pipx
- else
- die "grip installs with uv or pipx and neither is on PATH. Get uv with
- curl -LsSf https://astral.sh/uv/install.sh | sh
- then run this again, or run: uv tool install grip-hook"
- fi
- if [ "$UNINSTALL" = 1 ]; then
- case "$tool" in
- uv) uv tool uninstall grip-hook ;;
- pipx) pipx uninstall grip-hook ;;
- esac
- exit 0
- fi
- say "installing $spec with $tool"
- # --force replaces an older grip on PATH, such as a binary from an earlier install.sh.
- case "$tool" in
- uv) uv tool install --force "$spec" ;;
- pipx) pipx install --force "$spec" ;;
- esac
- if command -v grip >/dev/null 2>&1; then
- say "installed $(grip --version)"
- else
- say "installed, but grip is not on your PATH yet. Run '$tool ensurepath' (uv: 'uv tool update-shell') and open a new shell."
- fi
- say "next: cd into a repository and run 'grip init' (docs: https://guilyx.github.io/grip/)"
scripts/launch/make_launch.py · Bundled script · 354 lines · 2 findings marked
- """Build the launch assets from the recorded demo.
- python scripts/launch/make_launch.py
- Writes to ``docs/assets``:
- * ``demo.mp4``: the demo as H.264, for LinkedIn, X and anything that dislikes WebM.
- * ``launch/grip-producthunt-1270x760.png``: Product Hunt gallery image.
- * ``launch/grip-thumbnail-240.png`` and ``-480.png``: the mark, square.
- * ``launch/grip-launch-1080p.mp4``: an 84 second launch video, title cards around the demo,
- with a silent stereo track so upload sites treat it as a normal video.
- Needs the ``demo`` extra (Pillow, imageio-ffmpeg) and ``docs/assets/demo.webm`` from
- ``scripts/demo/make_demo.py``. Colours, fonts and the mark come from
- ``scripts/demo/brandkit.py``, so everything matches the docs and ``branding/``.
- """
- from __future__ import annotations
- import shutil
- import subprocess
- import sys
- from pathlib import Path
- from PIL import Image, ImageDraw, ImageFilter, ImageFont
- ROOT = Path(__file__).resolve().parents[2]
- sys.path.insert(0, str(ROOT / "scripts" / "demo"))
- from brandkit import colour, dot_grid, mark_image # noqa: E402
- from brandkit import font as brand_font # noqa: E402
- ASSETS = ROOT / "docs" / "assets"
- OUT = ASSETS / "launch"
- DEMO = ASSETS / "demo.webm"
- DEMO_MP4 = ASSETS / "demo.mp4"
- # Frames of the demo where the two score panels are fully drawn.
- FAIL_AT, PASS_AT = 16.0, 49.0
- DEMO_SECONDS = 54.0
- BG = colour("graphite-975")
- CARD = colour("graphite-950")
- FG = colour("graphite-50")
- DIM = colour("graphite-300")
- MUTED = colour("graphite-500")
- EMBER = colour("ember-400")
- CODE = colour("ember-300")
- PASS = colour("jade-300")
- FAIL = colour("berry-300")
- # Launch kinds to brand fonts: Archivo for display, Instrument Sans for text.
- KINDS = {"bold": "display-800", "regular": "text", "strong": "text-bold", "mono": "mono",
- "wordmark": "display"} # fmt: skip
- def font(kind: str, size: int) -> ImageFont.FreeTypeFont:
- """The brand font for ``kind`` at ``size`` pixels."""
- return brand_font(KINDS[kind], size)
- def fit(
- d: ImageDraw.ImageDraw, text: str, kind: str, size: int, width: float
- ) -> ImageFont.FreeTypeFont:
- """``font(kind, size)``, shrunk until ``text`` fits in ``width`` pixels."""
- f = font(kind, size)
- while size > 8 and d.textlength(text, font=f) > width:
- size -= 1
- f = font(kind, size)
- return f
- def find_ffmpeg() -> str:
- """An ffmpeg with libx264: imageio-ffmpeg's bundled build, else one on PATH."""
- try:
- import imageio_ffmpeg # noqa: PLC0415 - optional dependency
- return str(imageio_ffmpeg.get_ffmpeg_exe())
- except ImportError:
- pass
- found = shutil.which("ffmpeg")
- if found:
- return found
- raise SystemExit("ffmpeg not found: pip install imageio-ffmpeg, or install ffmpeg")
- FF = find_ffmpeg()
- def ffmpeg(*args: str) -> None:
- """Run ffmpeg quietly, overwriting outputs."""
- subprocess.run([FF, "-y", "-hide_banner", "-loglevel", "error", *args], check=True)
- # --------------------------------------------------------------------------- drawing helpers
- def surface(size: tuple[int, int]) -> Image.Image:
- """The brand surface: graphite-975 with the faint dot grid."""
- img = Image.new("RGB", size, BG)
- dot_grid(ImageDraw.Draw(img), *size, step=max(28, size[0] // 60))
- return img
- def rounded(img: Image.Image, radius: int) -> Image.Image:
- """``img`` with rounded corners (alpha)."""
- mask = Image.new("L", img.size, 0)
- ImageDraw.Draw(mask).rounded_rectangle((0, 0, img.width - 1, img.height - 1), radius, fill=255)
- out = img.convert("RGBA")
- out.putalpha(mask)
- return out
- def shadowed(canvas: Image.Image, card: Image.Image, xy: tuple[int, int], blur: int = 28) -> None:
- """Paste ``card`` on ``canvas`` with a soft drop shadow."""
- x, y = xy
- shadow = Image.new("RGBA", (card.width + blur * 4, card.height + blur * 4), (0, 0, 0, 0))
- ImageDraw.Draw(shadow).rounded_rectangle(
- (blur * 2, blur * 2 + 10, blur * 2 + card.width, blur * 2 + card.height + 10),
- 18,
- fill=(0, 0, 0, 170),
- )
- shadow = shadow.filter(ImageFilter.GaussianBlur(blur))
- canvas.alpha_composite(shadow, (x - blur * 2, y - blur * 2))
- canvas.alpha_composite(card, (x, y))
- def label(
- d: ImageDraw.ImageDraw, xy: tuple[int, int], text: str, color: str, f: ImageFont.FreeTypeFont
- ) -> None:
- """A small outlined tag."""
- x, y = xy
- tw = d.textlength(text, font=f)
- d.rounded_rectangle((x, y, x + tw + 22, y + f.size + 14), 8, fill=CARD, outline=color, width=2)
- d.text((x + 11, y + 7 - f.getbbox(text)[1]), text, fill=color, font=f)
- def centred(
- d: ImageDraw.ImageDraw,
- y: float,
- text: str,
- color: str,
- f: ImageFont.FreeTypeFont,
- *,
- width: int,
- ) -> None:
- """Draw ``text`` centred horizontally at ``y``."""
- d.text(((width - d.textlength(text, font=f)) / 2, y), text, fill=color, font=f)
- # --------------------------------------------------------------------------- assets
- def demo_frames(workdir: Path) -> tuple[Image.Image, Image.Image]:
- """The blocked and passed frames of the demo."""
- fail, pas = workdir / "fail.png", workdir / "pass.png"
- ffmpeg("-ss", str(FAIL_AT), "-i", str(DEMO), "-frames:v", "1", str(fail))
- ffmpeg("-ss", str(PASS_AT), "-i", str(DEMO), "-frames:v", "1", str(pas))
- return Image.open(fail), Image.open(pas)
- def demo_mp4() -> Path:
- """The demo as H.264 MP4 with a faststart header."""
- ffmpeg(
- "-i", str(DEMO),
- "-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2",
- "-c:v", "libx264", "-pix_fmt", "yuv420p", "-profile:v", "high", "-crf", "18",
- "-preset", "slow", "-r", "24", "-movflags", "+faststart", "-an", str(DEMO_MP4),
- ) # fmt: skip
- return DEMO_MP4
- def gallery(fail_frame: Image.Image, pass_frame: Image.Image) -> Path:
- """Product Hunt gallery image: pitch on the left, the two real score panels on the right."""
- w, h = 1270, 760
- img = surface((w, h)).convert("RGBA")
- scale = 0.64
- fail = fail_frame.crop((10, 480, 890, 590))
- pas = pass_frame.crop((10, 222, 890, 588))
- fail = fail.resize((int(fail.width * scale), int(fail.height * scale)), Image.LANCZOS)
- pas = pas.resize((int(pas.width * scale), int(pas.height * scale)), Image.LANCZOS)
- cx = w - fail.width - 48
- column = cx - 72 - 48
- x = 72
- img.alpha_composite(mark_image(84), (x, 92))
- d = ImageDraw.Draw(img)
- d.text((x + 108, 84), "grip", fill=FG, font=font("wordmark", 92))
- d.text((x, 206), "keep a grip on your code", fill=EMBER, font=font("strong", 26))
- y = 270
- head = ("A git hook that quizzes", "you on your own diff", "before you push.")
- hf = fit(d, max(head, key=len), "bold", 42, column)
- for line in head:
- d.text((x, y), line, fill=FG, font=hf)
- y += hf.size + 12
- y += 24
- for line in ("5 questions. A score out of 100.", "Under the pass mark, the push is blocked."):
- d.text((x, y), line, fill=DIM, font=font("regular", 24))
- y += 34
- y += 26
- install = "curl -fsSL guilyx.github.io/grip/install.sh | sh"
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 201 on GitHub
- d.text((x, y), install, fill=CODE, font=fit(d, install, "mono", 19, column))
- y += 40
- providers = "Claude Code · Codex · Gemini CLI · API key · Ollama"
- d.text((x, y), providers, fill=MUTED, font=fit(d, providers, "regular", 19, column))
- d.text((x, h - 58), "github.com/guilyx/grip", fill=MUTED, font=font("mono", 19))
- shadowed(img, rounded(fail, 14), (cx, 96))
- shadowed(img, rounded(pas, 14), (cx, 96 + fail.height + 70))
- d = ImageDraw.Draw(img)
- small = font("strong", 17)
- label(d, (cx, 96 + fail.height + 16), "lazy answers", FAIL, small)
- label(d, (cx, 96 + fail.height + 70 + pas.height + 16), "after reading the diff", PASS, small)
- path = OUT / "grip-producthunt-1270x760.png"
- img.convert("RGB").save(path, optimize=True)
- return path
- def thumbnail() -> Path:
- """Square icon: the mark on its tile."""
- img = mark_image(480)
- img.resize((240, 240), Image.LANCZOS).save(OUT / "grip-thumbnail-240.png", optimize=True)
- path = OUT / "grip-thumbnail-480.png"
- img.save(path, optimize=True)
- return path
- def card(lines: list[tuple[str, str, str, int]], *, mark: int = 0) -> Image.Image:
- """A 1920x1080 title card. ``lines`` are (text, font kind, colour, size), centred."""
- w, h = 1920, 1080
- img = surface((w, h)).convert("RGBA")
- d = ImageDraw.Draw(img)
- fonts = [fit(d, text, kind, size, w - 240) for text, kind, _, size in lines]
- gap = 26
- total = sum(f.size for f in fonts) + gap * (len(lines) - 1) + (mark + 48 if mark else 0)
- y = (h - total) / 2 - 20
- if mark:
- img.alpha_composite(mark_image(mark), ((w - mark) // 2, int(y)))
- y += mark + 48
- for (text, _, color, _), f in zip(lines, fonts, strict=True):
- top = f.getbbox(text)[1] if text else 0
- centred(d, y - top, text, color, f, width=w)
- y += f.size + gap
- return img.convert("RGB")
- def backdrop() -> Image.Image:
- """The frame the demo plays in."""
- w, h = 1920, 1080
- img = surface((w, h)).convert("RGBA")
- img.alpha_composite(mark_image(56), (70, 34))
- d = ImageDraw.Draw(img)
- d.text((142, 30), "grip", fill=FG, font=font("wordmark", 44))
- context = "pre-commit hook · amr-safety · a ROS 2 cmd_vel filter gains a scan watchdog"
- d.text((290, 50), context, fill=MUTED, font=font("regular", 24))
- f = font("mono", 24)
- url = "github.com/guilyx/grip"
- d.text((w - 70 - d.textlength(url, font=f), 50), url, fill=MUTED, font=f)
- return img.convert("RGB")
- CARDS: list[tuple[str, float, list[tuple[str, str, str, int]]]] = [
- ("c1", 3.5, [("grip", "wordmark", FG, 200), ("keep a grip on your code", "strong", EMBER, 52)]),
- ("c2", 4.0, [
- ("We ship more code with AI than ever.", "bold", FG, 76),
- ("And explain less of it.", "bold", DIM, 76),
- ]),
- ("c3", 5.0, [
- ("Ask a dev to walk you through a PR from last week.", "regular", FG, 56),
- ("Why that guard clause is there.", "regular", DIM, 56),
- ("What happens when the list is empty.", "regular", DIM, 56),
- ]),
- ("c4", 4.0, [
- ("grip quizzes you on your own diff", "bold", FG, 76),
- ("before it goes upstream.", "bold", EMBER, 76),
- ]),
- ("c5", 3.5, [
- ("5 questions · score out of 100", "bold", FG, 64),
- ("under the pass mark, the push is blocked", "regular", DIM, 48),
- ]),
- ("demo", DEMO_SECONDS, []),
- ("c6", 5.0, [
- ("One curl to install.", "bold", FG, 72),
- ("curl -fsSL guilyx.github.io/grip/install.sh | sh", "mono", CODE, 40),
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 285 on GitHub
- ("", "regular", FG, 10),
- ("Claude Code · Codex · Gemini CLI · API key · Ollama", "regular", DIM, 40),
- ]),
- ("c7", 5.0, [
- ("Owning your code is still on you.", "bold", FG, 76),
- ("github.com/guilyx/grip", "mono", EMBER, 48),
- ]),
- ] # fmt: skip
- # Cards that open and close the video carry the mark.
- MARKED = {"c1": 160, "c7": 112}
- def launch_video(workdir: Path) -> Path:
- """Title cards, the demo in a frame, closing cards; 1080p, 24 fps, fades between segments."""
- fade = 0.5
- inputs: list[str] = []
- filters: list[str] = []
- idx = 0
- for name, seconds, lines in CARDS:
- if name == "demo":
- bd = workdir / "backdrop.png"
- backdrop().save(bd)
- inputs += ["-i", str(bd), "-i", str(DEMO)]
- filters.append(
- f"[{idx}:v]loop=loop=-1:size=1:start=0,fps=24,trim=duration={seconds},"
- f"setpts=PTS-STARTPTS[bd];"
- f"[{idx + 1}:v]fps=24,scale=1230:916:flags=lanczos,setpts=PTS-STARTPTS[dm];"
- f"[bd][dm]overlay=(W-w)/2:120:shortest=1,"
- f"fade=t=in:st=0:d={fade},fade=t=out:st={seconds - fade}:d={fade},"
- f"format=yuv420p[v{name}]"
- )
- idx += 2
- continue
- png = workdir / f"{name}.png"
- card(lines, mark=MARKED.get(name, 0)).save(png)
- inputs += ["-loop", "1", "-t", str(seconds), "-i", str(png)]
- filters.append(
- f"[{idx}:v]fps=24,fade=t=in:st=0:d={fade},fade=t=out:st={seconds - fade}:d={fade},"
- f"format=yuv420p[v{name}]"
- )
- idx += 1
- concat = "".join(f"[v{name}]" for name, _, _ in CARDS) + f"concat=n={len(CARDS)}:v=1:a=0[v]"
- out = OUT / "grip-launch-1080p.mp4"
- ffmpeg(
- *inputs,
- "-f", "lavfi", "-i", "anullsrc=channel_layout=stereo:sample_rate=48000",
- "-filter_complex", ";".join([*filters, concat]),
- "-map", "[v]", "-map", f"{idx}:a",
- "-c:v", "libx264", "-preset", "slow", "-crf", "18", "-r", "24",
- "-c:a", "aac", "-b:a", "96k", "-shortest", "-movflags", "+faststart", str(out),
- ) # fmt: skip
- return out
- def main() -> None:
- """Build everything."""
- if not DEMO.exists():
- raise SystemExit(f"{DEMO} is missing; run scripts/demo/make_demo.py first")
- OUT.mkdir(parents=True, exist_ok=True)
- workdir = ROOT / "build" / "launch"
- workdir.mkdir(parents=True, exist_ok=True)
- fail_frame, pass_frame = demo_frames(workdir)
- for path in (demo_mp4(), gallery(fail_frame, pass_frame), thumbnail(), launch_video(workdir)):
- print(f"wrote {path.relative_to(ROOT)} ({path.stat().st_size / 1e6:.1f} MB)")
- if __name__ == "__main__":
- sys.exit(main())
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.