Files
Harvey_Team_Page/Work_files/Planet/NOTES.md
T
2026-08-26 12:45:51 +03:00

94 lines
7.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Planet — export settings (locked 2026-08-18)
## Source
- 601 PNG, 700×700, RGBA (alpha), `Planet_4.0000.png … Planet_4.0600.png`
- 24 fps → 25.04 s per revolution (601 frames ≈ 360°)
## Deliverables (`G:\Project\Association\Work_files\Planet`)
| File | Frames | FPS | Duration | Size | Res |
|---|---|---|---|---|---|
| `planet.webp` | 601 (all + loop frame) | 30 | 20.0 s/rev | 9.32 MB | 400×311 |
| `planet_15fps.webp` | 300 (odd 1,3,…,599) | 20 | **15.0 s**/rev | 4.65 MB | 400×311 |
| `planet_mobile.webp` | 150 (every 4th) | 10 | 15.0 s/rev | 1.45 MB | 320×249 |
| `seq/Planet_seq_0001..0300.webp` | 300 (odd) | — | per-frame | 5.6 MB total | 400×311 |
| `seq600/Planet_seq600_0001..0600.webp` | 600 | — | per-frame | 11 MB total | 400×311 |
All: WebP lossy **q70**, **alpha**, **loop 0** (infinite), open access (Everyone: R).
### Loop seamlessness (verified programmatically, 2026-08-18)
- Source: 601 frames = 359.4° + 0.6° (not exactly 360°).
- `planet.webp` (601 frames, 30fps): seam 600→0 = 0.6° = normal step, ratio 1.2 — within step variance. ✓
- `planet_15fps.webp`: odd selection 1,3,…,599 (seam ratio 1.34, least-bad; even selections are worse: 300→1.36 jump, 301→0.84 hold).
- ANMF flags: blend=0, dispose=0, full canvas — browser cannot layer frames.
- ⚠️ Do NOT measure the seam with a diff metric AFTER hqdn3d: temporal denoise shrinks consecutive-frame diffs and inflates the seam (14 vs 7.4 = false alarm). Measure on raw frames.
## Encoding parameters (smooth variant = `planet.webp`)
- Frames: **all 601** (0..600; frame 600 = loop-closing ≈ frame 0). Seam 600→0 = normal step (ratio 1.2, in-range)
- Speed: **30 fps** = 20 s per revolution (faster than source 25 s; for 25 s use 24 fps, for 40 s use 15 fps; fps does not affect size)
- Canvas: 400×311 (crop to union alpha bbox: rows 49..587, cols 3..695 — empty top/bottom removed, protruding car kept)
- Quality: q70 (q60–q75 visually identical on this content)
- **Edge defringe**: semi-transparent boundary pixels recolored to nearest opaque color (were near-black RGB 7,8,7 → dark halo on site bg; now 66,109,78)
- **RGB under α=0** filled with surface color (60,157,63) — protects against lossy-encoder chroma smearing into the visible edge
- **Denoise** `hqdn3d=4:3:6:4.5` — removes lossy-WebP temporal shimmer, saves ~35% size. ⚠️ **CRITICAL: hqdn3d does not support yuva420p and silently drops alpha** (RGBA→yuv420p). Alpha-preserving chain required:
`-vf "split=2[a][b];[a]hqdn3d=4:3:6:4.5[c];[b]alphaextract[d];[c][d]alphamerge"`
## Reproduction
```bash
# 1. preprocessing (crop+defringe+fill) — script process.py, see session history
# 2. encode (alpha preserved):
ffmpeg -y -framerate 30 -i "tmp_frames/f%04d.png" \
-vf "split=2[a][b];[a]hqdn3d=4:3:6:4.5[c];[b]alphaextract[d];[c][d]alphamerge" \
-c:v libwebp -quality 70 -loop 0 planet.webp
# 15fps/15s variant: -frames:v 300 -framerate 40 -vf "...alphamerge,select='mod(n\,2)'" (input 40fps → selected 20fps = 50ms)
# seq600 (600 frames): -frames:v 600, no select
# seq (300 frames): -frames:v 300 + select odd
```
⚠️ With `select`, the input framerate must be 2× the target output rate (input 40 → output 20), otherwise timestamps survive and the duration doubles. Do NOT use the `fps` filter for re-timing — it RESAMPLES (duplicates frames) instead of re-stamping.
## Site embedding (important — “frame layering”)
Symptom «layers of old frames, resetting at cycle restart» = **naive playback-side compositing**, NOT a file defect. Proven: ANMF blend=0, dispose=0, full canvas (spec forbids accumulation); decode clean (each frame = own content, err 6.0 vs 7.7 for neighbors); naive drawImage-without-clear simulation reproduces the symptom (ghost up to 254 in the margin over 40 frames).
- ✅ Correct: `<img src="planet.webp">` directly — browser replaces frames, no accumulation.
- ✅ Canvas/JS with a sequence: **always `ctx.clearRect(0,0,w,h)` before each `drawImage`** — transparent pixels do not erase the canvas; without clearing, layers accumulate.
- ⚠️ If “layering” is visible even in a plain `<img>` — the player/composer preview renders WebP ignoring the flags (player bug; the file is clean).
## LCP posters (planet_poster*.webp, 2026-08-19, perf card t_d7e3d206)
Frame 0 stills of the animated loops, used as the LCP-critical image (poster-first pattern, R1):
| File | Source | Res | Size |
|---|---|---|---|
| `planet_poster_mobile.webp` | frame 0 of planet_mobile.webp | 320×249 | 10.5 KB |
| `planet_poster.webp` | frame 0 of planet_15fps.webp | 400×311 | 16.5 KB |
Encoding: PIL `frame.convert("RGBA").save(out, "WEBP", quality=75, method=6)` — see `make_posters.py`.
Landing markup: plain `<img>`+srcset (`320w`/`400w`, `sizes="(min-width:768px) 480px, 320px"`), `fetchpriority="high"`, `decoding="async"`; planet.js swaps to the animated webp after `window.load`. ⚠️ With `srcset` present, `img.src` changes are ignored — JS must `removeAttribute('srcset')` before swapping.
Measured (CDP, emulated 4G 1.6 Mbps/150 ms RTT): LCP 1.2 s mobile + desktop; animated webp loads in background post-LCP (mobile 1.45 MB ≈ 7.6 s, desktop 4.65 MB ≈ 23 s).
## Mobile variant (planet_mobile.webp, 2026-08-19)
Source: seq600 per-frame WebP (already q70 lossy — no PNG masters on disk; re-encode from there).
Probes (all: alpha preserved, loop 0, 15.0 s/rev, alpha-preserving hqdn3d chain, defringe inherited from source):
| Probe | Frames | Res | Q | cl | Size | MAE* | Adj-step† |
|---|---|---|---|---|---|---|---|
| p1_q55_320 | 200 (every 3rd) | 320×249 | 55 | 4 | 2.05 MB | 8.73 | 9.82 |
| p6_q50_150fr | 150 (every 4th) | 320×249 | 50 | 4 | 1.50 MB | 8.98 | — |
| **p7 → `planet_mobile.webp`** | **150 (every 4th)** | **320×249** | **50** | **6** | **1.45 MB** | **9.02** | **11.22** |
| p8_q45_150fr | 150 | 320×249 | 45 | 4 | 1.45 MB | 9.13 | — |
| p9_q50_300 | 150 | 300×233 | 50 | 6 | 1.32 MB | 9.15 | 11.18 |
| p10_q50_120fr | 120 (every 5th) | 320×249 | 50 | 6 | 1.16 MB | 9.08 | 12.47 |
*MAE vs source frame scaled to probe res (opaque px, RGB). †adjacent-frame MAE = stepping proxy: 150fr = +14% vs 200fr, 120fr = +27%.
Encoding (from seq600, input 40fps so select re-stamps to 10 fps → 15 s/rev):
```bash
ffmpeg -y -framerate 40 -i "seq600/Planet_seq600_%04d.webp" \
-vf "split=2[a][b];[a]hqdn3d=4:3:6:4.5[c];[b]alphaextract[d];[c][d]alphamerge,select='not(mod(n\,4))',scale=320:249:flags=lanczos" \
-frames:v 150 -c:v libwebp -quality 50 -compression_level 6 -loop 0 planet_mobile.webp
```
Seam verified: seam_ratio 1.23 ≈ internal step (2.4°/frame) — seamless. Trade-off: 10 fps / 2.4° per frame is slightly steeper than desktop variants (1.2°); acceptable on mobile hero. If smoother is preferred use 200-frame q45 (≈1.85 MB) or drop to q45/120fr (1.16 MB, p10).
## Speed (single number to change)
| Desired revolution | fps | Command |
|---|---|---|
| 20 s (current 30fps file) | 30 | as above |
| 15 s (current 15fps file) | 20 | `-framerate 40` + odd select |
| 25 s (like source) | 24 | `-framerate 24` |
| 40 s (slower) | 15 | `-framerate 15` |