diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-11 06:49:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-11 06:50:11 -0300 |
| commit | 378379807fb4cd751e90808c8363caddb365bcd8 (patch) | |
| tree | f84c7d0e7cbd42a9b9c93e791ab2b5376499d23d /design/motion/motion.py | |
| parent | 5922ee911b9a6604f60dc83be36ba9e6c9abac98 (diff) | |
| download | computeranim-378379807fb4cd751e90808c8363caddb365bcd8.tar.gz computeranim-378379807fb4cd751e90808c8363caddb365bcd8.zip | |
canim: nothing changes in one frame; the map's space is used; the heap scene at its storyboard's length
The motion check counts a third of the one-frame changes it did: the
minimap's changes fade, and a register's value, a flag, a role, a pin's
names, a tag's note, a backtrace row, a call tree's node and a dump row
crossfade where they changed at once. What still fires is named in the
README; an encoder's keyframe and the gallery's cuts are exempt by name.
No caption stands over twelve seconds or under its reading time. The
heap scene is 78 s: what the storyboard does not narrate runs, and each
free's line cascades onto its call row (line stepping stops at a
breakpoint for that). On the map, leftover space holds the stack
continued, dumps round what the registers and the stack point at, open
loupes and the key: between 1% and 13% of a map is page, where it was 14%
to 42%.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'design/motion/motion.py')
| -rw-r--r-- | design/motion/motion.py | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/design/motion/motion.py b/design/motion/motion.py index d192295..66571be 100644 --- a/design/motion/motion.py +++ b/design/motion/motion.py @@ -189,6 +189,22 @@ def report(video, names, counts, soft, sizes, fps): WORDS = ("head", "caption", "clock", "minimap") # regions that are not panels +# One-frame changes that are right, by name: each a test of (region, frame, pixels moved there) that says +# whether the POP at that frame is one of its kind. They are counted apart, never silently dropped. +# `keyframe`: the encoder's, not the scene's: a few pixels of a still region re-quantized at an I frame. +KEYFRAMES = set() # the video's I frames (cmd_chart reads them) +EXEMPT = {"keyframe": lambda name, t, moved: t in KEYFRAMES and moved < 200} + + +def keyframes(video): + out = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-skip_frame", "nokey", "-show_entries", + "frame=pts", "-of", "csv=p=0", video], capture_output=True, text=True, check=True) + fps, _ = probe(video) + tb = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=time_base", + "-of", "csv=p=0", video], capture_output=True, text=True, check=True).stdout.strip().split("/") + per = fps * int(tb[0]) / int(tb[1]) + return {int(round(int(line) * per)) for line in out.stdout.split() if line.strip().lstrip("-").isdigit()} + def lint(names, counts, soft, sizes, fps, ev): """What a viewer would trip on, found by rule. Each line: what, how often, the first few times.""" @@ -200,17 +216,29 @@ def lint(names, counts, soft, sizes, fps, ev): # POP: a region still for STILL frames changes in one frame and is still again, at any size: a label # swapped, a box gone, a count appearing. Nothing eased it. (And, as before, a large change in two.) - pops = {e["from"] for e in ev if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002} + pops, exempt = set(), {} + for e in ev: + if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002: + kind = next((n_ for n_, test in EXEMPT.items() if test("all", e["from"], e["peak"])), None) + exempt.setdefault(kind, set()).add(e["from"]) if kind else pops.add(e["from"]) for k in range(1, len(names)): if names[k] == "clock": # its count changes in a frame by design: it is time, not a thing continue col = on[:, k] for t in range(STILL, len(col) - 1): if col[t] and not col[t + 1] and not col[t - STILL:t].any() and counts[t, k] >= MIN_PX: - pops.add(t) + kind = next((n_ for n_, test in EXEMPT.items() if test(names[k], t, counts[t, k])), None) + if kind: + exempt.setdefault(kind, set()).add(t) + else: + pops.add(t) pops = sorted(pops) if pops: out.append(f" POP {len(pops):3d} a change in one frame after stillness: {some([t / fps for t in pops])}") + for kind, ts in sorted(exempt.items()): + ts = sorted(ts - set(pops)) + if ts: + out.append(f" POP exempt {len(ts):3d} {kind}: {some([t / fps for t in ts])}") # CROWD: three or more panels begin to move within two frames of each other. crowd = [] @@ -249,7 +277,8 @@ def lint(names, counts, soft, sizes, fps, ev): longs.append(b / fps) elif 6 < up < 90: # 6: a caption leaving and the next arriving shorts.append(b / fps) - later = np.nonzero(on[b + 1:, panels].any(axis=1))[0] + later = [i for i in np.nonzero(on[b + 1:, panels].any(axis=1))[0] + if not ({b + 1 + i, b + i} & KEYFRAMES and counts[b + 1 + i, panels].max() < 200)] # the encoder's (an I frame and the one after it), not the picture's if len(later) and later[0] < 60 and up >= 90: late.append(b / fps) for what, times in (("up over 720 f (12 s)", longs), ("up under 90 f", shorts), @@ -315,6 +344,8 @@ def chart(video, names, counts, soft, sizes, fps, ev, path, per_row=10.0): def cmd_chart(a): fps, _ = probe(a.video) + KEYFRAMES.clear() + KEYFRAMES.update(keyframes(a.video)) regions = regions_for(a.video, a.regions) names, counts, soft, sizes = measure(a.video, regions) ev, text = report(a.video, names, counts, soft, sizes, fps) |
