Skip to content

feat(fled): self-describing video container with embedded screenmap (Phase 1) - #126

Merged
zackees merged 3 commits into
mainfrom
feat/fled-container-phase1
Jun 15, 2026
Merged

zackees merged 3 commits into
mainfrom
feat/fled-container-phase1

Conversation

@zackees

@zackees zackees commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Closes #122 (Phase 1). Companion: FastLED/FastLED#3063.

Summary

  • New .fled container: 12-byte header (magic + version + pixel_format + reserved + json_length) followed by UTF-8 JSON (screenmap + optional video.fps) followed by the raw frame payload. Pixel format lives in the binary header so consumers can slice frames without parsing JSON. v1 emits rgb8; the enum reserves gray8 / rgba8 / rgbw8 / rgb565le for future PRs (no version bump needed).
  • Generator (src/moviemaker/recording.ts) wraps the flat RGB payload in a FLED header carrying the live screenmap JSON. Download extension is now .fled. IndexedDB persistence saves the headered buffer.
  • Consumer (src/movieplayer/) is rewritten as embedded-only: the screenmap upload UI, drop zone, preset buttons, and dependencies on screenmap-store / preset-loader are removed. The embedded JSON drives the screenmap; LED count derives from it. Legacy headerless videos in IndexedDB are dropped silently on startup.
  • Shared parser (src/render/rgb-video.ts) is the single source of truth for both ends. Exports buildFledHeader, prependFledHeader, hasFledMagic, plus an extended parseRgbFrames returning embeddedJson / pixelFormat / fledError.
  • Canonical spec: docs/fled-format.md — full binary layout, pixel format enum table, JSON schema, versioning rules, backwards-compat rules, and a 46-byte reference vector.

Verification

  • npm run lint — clean
  • npm test — 424/424 pass (14 new in tests/unit/rgb-video.test.ts)
  • npm run build — succeeds
  • Integration tests updated: tests/integration/movieplayer.spec.ts for embedded-only UX; tests/integration/moviemaker-recording.spec.ts strips the FLED header before per-frame byte checks
  • Manual: load a 64x64 preset in moviemaker, record a few seconds, navigate to movieplayer — video auto-plays with the right LED count and no separate screenmap upload prompted

Out of scope

  • MPEG1 / MP4 phases — separate PRs per the FastLED issue
  • gray8 / rgba8 / rgbw8 / rgb565le generator support — spec is locked, encoders land with their use cases
  • WASM jsSetScreenMapsFromJson binding — FastLED side, tracked in #3063

🤖 Generated with Claude Code

zackees and others added 3 commits June 14, 2026 22:57
Introduces the FLED v1 container format. Recorded LED-data videos and
their screenmap now travel as a single .fled file instead of as a
separate .rgb + screenmap.json pair. See docs/fled-format.md for the
canonical spec.

Wire format (12-byte fixed header):

    offset  size  field
    0       4     magic "FLED"
    4       1     version = 1
    5       1     pixel_format (enum)
    6       2     reserved
    8       4     json_length (u32 LE)
    12      N     json_bytes (UTF-8)
    12+N    ...   payload (frames)

Pixel format goes in the binary header so consumers can slice frames
without parsing JSON. v1 emits rgb8 (0x00); the enum reserves 0x01–0x04
for gray8/rgba8/rgbw8/rgb565le, each of which can ship later without a
version bump. Unknown formats reject cleanly. JSON gains an optional
video.fps field next to the existing map.

Generator (src/moviemaker/recording.ts): wraps the flat RGB buffer in a
FLED header carrying the active screenmap JSON. Download extension is
now .fled. IndexedDB persistence saves the headered buffer.

Consumer (src/movieplayer): the side-loaded screenmap workflow is gone.
Movie Player only accepts .fled files; the embedded JSON drives the
screenmap and the LED count derives from it. Legacy headerless videos
in IndexedDB are dropped silently on startup. The screenmap upload
input, the screenmap drop zone, the preset buttons, and the dependency
on screenmap-store / preset-loader were removed.

Shared parser (src/render/rgb-video.ts): single source of truth for
both ends. buildFledHeader, prependFledHeader, hasFledMagic, and an
extended parseRgbFrames returning embeddedJson / pixelFormat / fledError.

Tracking issues:
- #122 (generator, this PR closes Phase 1)
- FastLED/FastLED#3063 (consumer side)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…hase1

# Conflicts:
#	src/movieplayer/movieplayer.ts
#	src/movieplayer/template.html
…hase1

# Conflicts:
#	src/moviemaker/moviemaker.ts
@zackees
zackees merged commit 7fb56cc into main Jun 15, 2026
5 checks passed
@zackees
zackees deleted the feat/fled-container-phase1 branch June 15, 2026 06:15
zackees added a commit that referenced this pull request Jun 15, 2026
PR 1 of 6 for the layered single-page consolidation (#133).

- Demo's three sample videos (color_line_bubbles, video, video1)
  are converted from raw .rgb to self-describing .fled
  (one-shot scripts/convert-rgb-to-fled.mjs prepends the 12-byte
  FLED header + embedded 32x32 quad serpentine screenmap).
- demo.ts loads /demo/video.fled in one fetch + parseRgbFrames
  pass instead of chunk-streaming raw .rgb. The ~100 lines of
  ReadableStream bookkeeping (videoReader, videoBuffer,
  streamVideoData, processNewFrames, stopVideoStream) all drop
  out — parseRgbFrames already handles the FLED header.
- demo's upload + download flows operate on .fled. Download
  wraps the in-memory frames with the screenmap-embedding
  FLED header via prependFledHeader.
- src/demo/template.html: file input accepts="*.fled".
- src/hub/template.html: Movie Player tile copy updated.
- CLAUDE.md: Data Formats + tools table reflect .fled.
- src/types/domain.ts + src/video-store.ts: comments updated.

No behavioral change for the Movie Player (it already required
.fled after #126). The remaining .rgb references in moviemaker.ts
shaders / pixel-format names refer to the rgb8 pixel format
*inside* the FLED container, not the deprecated container.

Verified locally: tsc, lint, build, 433 unit tests, 6/6 smoke
tests all pass.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embed screenmap.json into recorded videos (raw .rgb, MPEG1, MP4) — kill the sidecar

1 participant