Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

docs: held drawings and the held-drawings retake reason; changelog

Soohong Kimcbf94780cb46
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3bde94..73b19f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased - A clip that shows each drawing for two or three frames is read as such, and the set alignment names a held loop it could not fill as a take to film again
+
+- **New: `video-cycle-align` names a loop to film again** (`retake`, reason `held-drawings`). A loop whose clip holds each drawing for two or three frames ("on twos", "on threes"), that the set's length leaves at under 13 drawings a second (`align.RETAKE_DRAWINGS_MIN`; a clip on twos shows 12), with one or more frames between its drawings not made (`align.RETAKE_UNMADE_MIN`: taken from the nearer source frame under `--between auto` or `nearest`, made with a fault and kept under `rife`), is listed in the report's `retake` (`dir`, `name`, `hold`, `source`, `drawings`, `drawings_per_second_filmed`, `drawings_per_second`, `frames_per_drawing`, `unmade`, `limits`) and in a warning line ("film this direction again (held-drawings) — …"). Where the legs swap places between two drawings no interpolator draws them, so each frame `auto` took from the nearer source frame holds a drawing a frame longer and the loop halts there; only a new take drawn every frame fixes it. The set is still aligned and written, exit 0: the reason is for the caller to act on, never silent. Each loop row and its `strip.json` `cycle_align` gain `drawings` (the hold, read from the clip's record) and `retake` (the record, or `null`); `video-set` carries `retake` per state and per item. A held loop at its own length (nothing made), a held loop whose made frames all kept their outline, one squeezed to 13 drawings a second or more, and a loop drawn every frame with a replaced frame are not named.
+- **New: `video-loop` records the clip's drawings** (`drawings` in the loop report and in `strip.json`, `hold`/`drawings_per_second` in the printed summary): whether the clip shows each drawing for one, two or three frames, how many drawings a second, the held steps, and `contrast` per hold as the evidence (`sprite_gen/video/held.py`), read over the whole clip as keyed, before the cut. The alignment reads the hold from `strip.json`: a cut cycle is short, and `--anchor motion-auto` shifts each cut frame so a pair's repeat may no longer read as one; a loop cut before this record is measured on its own cycle. The cut, the strip, the GIF and the WebP are unchanged.
+- **Why a rhythm and not a threshold**: a model rarely repeats a drawing as a byte copy — it redraws the second frame of a pair a little — and a rule that calls a step held under a fraction of the median step misses exactly that, because with half the steps held the median falls between the two kinds. The judgement reads, for a hold of 2 or 3, the phase whose every second or third step is the change, in windows of 12 steps: the held steps' median over the change steps' median, under 0.3 (`held.CONTRAST_MAX`). A clip drawn every frame whose steps alternate long and short, and a frame repeated now and then (a 20 fps clip carried at 24), read above it. [docs/loop-repair.md](docs/loop-repair.md#4-one-cycle-for-a-direction-set--video-cycle-align-video-set---align-cycles-auto), [docs/video-pipeline.md](docs/video-pipeline.md#4-loop--period-first-seam-second-then-the-gait-floor).
+
## v2.28.0 - A frame RIFE made whose legs melted is caught by the outline it lost, and the set alignment takes the nearer source frame there
- **Output change: which frames `video-cycle-align` keeps from RIFE.** `--between` gains `auto`, now the default (`video-set --align-between` too): every frame between two source frames is still made by RIFE and measured, and one that smeared or lost its outline takes the nearer source frame instead, named in the warnings. A set whose made frames all keep their outline comes out byte for byte as 2.27.0's; where one melted, that frame is now the nearer filmed frame, the loop's `cycle_align` gains `nearest_at` beside `made_at`, and `made_by_rife` counts only the frames kept. `--between rife` gives 2.27.0's frames, with the new warnings; `nearest` is unchanged.
diff --git a/SKILL.md b/SKILL.md
index 9abd04c..d644bd3 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -137,4 +137,4 @@ Scene creation consumes finished assets and remains optional. Asset metadata own
## Contracts and advanced tools
-[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted takes the nearer source frame) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)).
+[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted takes the nearer source frame) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)) — and a clip the engine names for one: when the alignment report's `retake` lists a loop (reason `held-drawings`: its clip shows each drawing for two or three frames, the set's length leaves it at under 13 drawings a second, and frames between its drawings could not be made, so the loop halts there), run the engine verbs first as above, then film that direction again and align the set anew rather than hand-painting the gap; tell the user what the reason was and that a new take usually fixes it ([loop-repair](docs/loop-repair.md) section 4).
diff --git a/docs/loop-repair.md b/docs/loop-repair.md
index edf6f3e..0c7ef7f 100644
--- a/docs/loop-repair.md
+++ b/docs/loop-repair.md
@@ -345,6 +345,46 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
steps as filmed, up to half a frame off its time, and the loop shows fewer distinct drawings a
second than `rife` — but no melted one. A clip drawn on twos has a long step between drawings
everywhere, so it is replaced most; the frames that land on a small step stay RIFE's.
+- **Held drawings — a take to film again** (`retake`, reason `held-drawings`): a loop whose
+ clip shows each drawing for two or three frames has a gap between drawings two or three frames
+ wide. Played at its own rate that is limited animation, 12 or 8 drawings a second. Made longer,
+ or merely resampled, the frames in each gap are made across a step two or three times as long
+ as an every-frame clip's, and where the legs swap places inside it — the near leg passing behind
+ — no interpolator draws them: a flow model blends the two drawings into a ghost or a melted
+ shape, which `auto` replaces with the nearer source frame, and that drawing is held a frame
+ longer: the loop halts there. A better interpolator is not the fix; a take drawn every frame is.
+ - **The hold is the clip's**: `video-loop` measures it over the whole clip as keyed and writes
+ it into `strip.json` (`drawings`: `hold`, `drawings_per_second`, `contrast`, `frames`; [video
+ pipeline](video-pipeline.md) section 4). The alignment reads it there (`source: "clip"`, the
+ cycle's drawings its frames at the clip's rate), and keeps it through a rebuild. A cut cycle is
+ too short to read a rhythm on reliably, and `--anchor motion-auto` shifts each cut frame, so a
+ pair's repeat may no longer read as one; only a loop cut before the record is measured on its
+ own cycle, read as a ring (`source: "cycle"`).
+ - **The rule**: a loop is named when its source is held (`hold` 2 or 3), the set's length leaves
+ it under **13 drawings a second** (`align.RETAKE_DRAWINGS_MIN`), and **one or more** frames
+ between its drawings were not made (`align.RETAKE_UNMADE_MIN`) — taken from the nearer source
+ frame (`auto`'s replacements, every made time under `nearest`) or made with a fault and kept
+ (`rife`). Each loop row carries `drawings` and `retake` (the record, or `null`): `reason`,
+ `hold`, `source`, `drawings` (in the cycle), `drawings_per_second_filmed`,
+ `drawings_per_second` (at the set's length), `frames_per_drawing` (the gap, in frames of the
+ aligned loop), `unmade`, and the `limits`. The report's `retake` lists every such loop (`dir`,
+ `name` and the same numbers), a warning line names it ("film this direction again
+ (held-drawings) — …", by its directory where two loops share a strip name), and `video-set`
+ carries both into its record.
+ - **Not named**: a held loop at its own length (nothing is made — on twos it plays at 12 a
+ second, as filmed), a held loop whose made frames all kept their outline, a held loop squeezed
+ to 13 drawings a second or more (its drawings come closer than on twos), and a loop drawn every
+ frame with a replaced frame (one soft step, not a gap the take cannot fill).
+ - **Exit code and words**: the set is still aligned and written (`applied: true`, exit 0) — the
+ loop is the best this take allows, and the caller decides: a pipeline with a retake budget
+ films that direction again and aligns the set anew; one without delivers it with the warning.
+ Nothing passes quietly: the line is on stderr and in `warnings`, and `retake` is the
+ machine-readable reason.
+ - **Why 13**: a clip on twos shows 12 drawings a second. At that rate or slower each frame not
+ made is a drawing held a frame longer at the moment the legs cross, which reads as a halt; a
+ line a little above 12 keeps a cut that is not all pairs, or a cycle made a frame or two
+ longer, on the same side. The lines are references, not measured optima, and a loop near them
+ is worth a look either way.
- **Foot strike**: each loop is then turned to start as a heel lands (`align.foot_strike`), read
off one signal smoothed 1-2-1 — never off the frame's top edge, which a long ear, a hat's
point or an antenna owns and which flops on its own rhythm:
@@ -396,7 +436,7 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
rewritten at the loop's own cell rules (`cell_height_cap`, body-height target, anchor), at the
loop's frame rate, so the aligned cycle lasts L*/fps seconds. `strip.json` gains
`cycle_align` (`from`, `to`, `between`, `taken`, `made_by_rife`, `made_at`, `smear` and/or
- `nearest_at`, `turned_by`, `turned_on`, `view`, `start_foot`, the seam ratio of the rebuilt
+ `nearest_at`, `drawings`, `retake`, `turned_by`, `turned_on`, `view`, `start_foot`, the seam ratio of the rebuilt
cells, and the re-verified GIF/WebP).
- **The cut as filmed is kept** in `cycle.source/` on the first alignment, and every later
alignment reads from there: running it again, or at another length, never resamples a
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index 02d55ff..3b9c268 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -755,6 +755,25 @@ filmed with a warning (`--repair on` fails instead). See [loop repair](loop-repa
moves are reported (`jolt`); beyond the reference bounds that is a warning line, and a gate
(`video-loop: loop jolts — …`) only when `--jolt-max` / `--head-step-max` are passed.
+**Held drawings: recorded on every loop.** A video model may film a walk at 12 drawings a second
+inside a 24 fps clip, each drawing shown for two frames ("on twos", or three: "on threes"). The
+report's `drawings` says so, read over the whole clip as keyed, before any cut
+(`sprite_gen/video/held.py`): `hold` (1 every frame a drawing, 2 or 3; `null` with a `why` for a
+clip too short or still), `drawings` and `drawings_per_second`, `held_steps`, and `contrast` per
+hold — the held steps over the change steps, the evidence. `strip.json` carries the same record
+(`drawings`: `hold`, `drawings_per_second`, `contrast`, `frames`) for `video-cycle-align`. The second frame of a pair is rarely a
+byte copy: the model redraws it a little, so its step is small, not zero, and a rule that calls a
+step held under a fraction of the median step misses it (with half the steps held the median falls
+between the two kinds). So the judgement reads the rhythm: for a hold of 2 or 3, in windows of 12
+steps, the phase whose every second (or third) step is the change, its held steps' median over its
+change steps' median; under 0.3 the clip is held, and each step is then held when it is under the
+geometric midpoint of the two kinds' means. A motion filmed every frame has no such rhythm — its
+steps swell and shrink with the stride over a dozen frames — and a clip whose steps alternate long
+and short but move every frame reads above it; so does a frame repeated now and then (a 20 fps
+clip carried at 24). Nothing is refused here: played at its own rate a held loop is ordinary
+limited animation. It matters when `video-cycle-align` stretches it ([loop repair](loop-repair.md)
+section 4, "Held drawings").
+
### One-shot actions — `--cycle auto|periodic|one-shot`
A video model asked to jump "over and over" sometimes jumps once and stands for the
@@ -886,7 +905,9 @@ auto`, the default; `off` keeps each loop's own length). The same step stands al
`sprite-gen video-cycle-align --loop-dir … --view …`. `set.report.json` carries `cycle_align`
per state (with `start_foot` per item), a failed alignment is listed as `cycle-align:<state>`,
and a made frame with a smear, one that melted and was replaced, or a loop whose foot could not be named is a line under
-`warnings`. Two cases skip the alignment with a warning instead of failing it (`applied: false`,
+`warnings`. A held loop stretched past what an interpolator bridges is named for a new take: the
+state's `retake` (reason `held-drawings`, with its numbers; per item under `cycle_align.retake`) and
+a warning line ([loop repair](loop-repair.md) section 4, "Held drawings"). Two cases skip the alignment with a warning instead of failing it (`applied: false`,
`reason`, and a line under the report's `warnings`): no RIFE (`rife-not-installed`), and a loop
that may hold more than one cycle (`cycle-suspects`, the loops under `suspects`; count them, then
`video-cycle-align --cycles <loop>=<k>`). See [loop repair](loop-repair.md) section 4.