Repository navigation
feat(protocol,electron): export the pixel video as MP4 instead of WebM - #174
Conversation
…he mobile-canonical name, instead of WebM The default file name of the video FileType is now video.mp4 (video.<n>.mp4 per display), and the manifest entry states format mp4, so the worker and the viewer take it as the default H.264 MP4 with no transcode. The host-supplied muxer / MediaRecorder encoder must now produce MP4. Refs #54 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Claude finished @krassx's task in 48s —— View job PR review: export pixel video as MP4 instead of WebMI read the diff and the surrounding code ( The rename is consistent. FindingsP2 Medium: the MP4 contract is not validated (inline comment on
P3 Low: stale docs.
Summary
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Summary
Change: Feature Merge Risk:
|
There was a problem hiding this comment.
Stale comment
Review: export pixel video as MP4
This PR does one production thing:
DEFAULT_FILENAMES.videobecomesvideo.mp4, somanifestEntryForTypenow stampsattrs.format: "mp4"and the worker/viewer skip the WebM transcode. Tests, comments, and the Electron design docs were updated to match. That alignment with Android’svideo.mp4is the right target — but the SDK still does not produce those bytes, and nothing checks that the host did.I traced the live path: host
VideoCaptureSource.snapshot→encodePixelVideo(verbatim copy) → assembler names the member fromDEFAULT_FILENAMESand derivesformatfrom the extension.createMediaRecorderVideoSourcestill concatenates whateverrecorderFactoryemits;createCapturePageVideoSourcestill dumps whateverencode()returns. Chromium’snew MediaRecorder(stream)(the seam’s own example, with no required mime type) defaults to WebM.P1 — High: renaming to
.mp4re-opens the WebM-as-MP4 mislabel this format attr exists to prevent
- Location:
packages/protocol/src/constants.ts:56(drivespackages/core/src/bundle-assembler.ts:288-298)- Problem:
formatis taken only from the canonical filename, never from the payload. After this change it is alwaysmp4, so the worker skips transcode even when the bytes are still WebM (EBML1a 45 df a3). The previousvideo.webm+format: "webm"pair was the thing that made the worker transcode host WebM/MJPEG into playable H.264.- Impact: Opt-in pixel video lands in the bundle, looks like mobile
video.mp4, and does not play. No SDK error, noonError. Same failure the assembler comments describe for a video entry with no attrs.- Scenario: A host wires the documented seam as
recorderFactory: () => new MediaRecorder(stream)(or{ mimeType: 'video/webm' }, or the previous webm/mjpegencodemuxer) and upgrades to this PR. Snapshot bytes are WebM; the member isvideo.mp4withformat: "mp4". Worker skips transcode; viewer labelsvideo/mp4.- Fix: Sniff magic at encode/assembly time (
ftypvs EBML) and set filename +formatfrom the bytes — keepformat: "webm"so the worker still transcodes when the host has not actually emitted H.264. Fail closed (drop video,onError) if the name is.mp4and the payload is notftyp. UpdaterecorderFactoryJSDoc to requirevideo/mp4;codecs=avc1andMediaRecorder.isTypeSupportedbefore claiming the new contract. Do not merge a hard MP4 label while the intended encoder is still unverified (the PR’s own open question).Residual (not filed)
- Chromium H.264 encode in MediaRecorder is platform-dependent; this repo has not run the pixel-video path on real Electron 45 (
README“Not run”). Linux/Electron builds that cannot emitvideo/mp4;codecs=avc1have no remaining transcode fallback after this change.encodePixelVideostill byte-concatenates multiple unlaned payloads. That is invalid ISO-BMFF (twoftyp/moovboxes). Display lanes are split and tested; a host that merges capturePage + MediaRecorder snapshots without lanes would still hit it.VideoLaunchOptions/ README still do not say the host must emit H.264 MP4.docs/design/backend-beta-readiness.mdstill says Electron video is WebM with no format attrs (stale; not in this diff).Tests I actually ran
@bugsee/protocolconstants/upload-contract/redaction.fuzz: 67 passed@bugsee/corebundle-assembler/bundle-stream-assembler: 117 passed@bugsee/electrone2e / display-video / pixel-video-controller / video-capture: 89 passed@bugsee/nodelaunch.test.ts: 182 passedFull GitHub CI (lint/coverage/e2e) was still in progress at review time. The suites above assert the new name and a fake
ftypprefix; none assert that host/MediaRecorder bytes actually are MP4, which is why the P1 survives them.Overall
- Overall risk: Medium — opt-in feature, unpublished SDK, but silent unplayable video for the feature this PR ships.
- Merge recommendation: Request changes.
- Most important to fix: Do not stamp
format: "mp4"unless the payload starts withftyp(or keepvideo.webm/format: "webm"until a real H.264 producer exists).- Positive: The rename is consistent (protocol → both assemblers → node/electron tests → design docs). Per-display
video.<n>.mp4+format: "mp4"is correct (nthFileName/manifestEntryForType). The e2e fake was updated off the EBML header onto anftypprefix instead of leaving a WebM fixture under an MP4 name.Sent by Cursor Automation: Bugsee code review
…tract Review findings: the manifest labels the entry format 'mp4' from the file TYPE alone and the worker skips its transcode for an MP4, but nothing checked the bytes, so a host encode/MediaRecorder that still yields WebM (Chromium's MediaRecorder default) would ship WebM labelled MP4 and not play, with no error. - the pixel-video controller checks the ftyp box of every video entry in snapshot(): WebM (named in the message) or anything else is dropped and reported through onError; the bundle still builds, without the video; other entry types are untouched - encode / MediaRecorder seam docs say what they must produce (an H.264 encoder plus an MP4 muxer; an MP4 mimeType) - electron.md states the contract (breaking for a host that supplied WebM); backend-beta-readiness.md's 'Electron video is WebM' item is marked resolved - tests: MP4-shaped fakes; WebM / short / wrong-box / non-bytes dropped with distinct messages; mutants on the check killed 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Claude finished @krassx's task in 40s —— View job Review of PR #174: export pixel video as MP4 instead of WebMI re-read the diff against Earlier findings: fixed by
|
There was a problem hiding this comment.
Stale comment
Re-review at 2e2f82f
Prior P1 (WebM labelled
video.mp4/format: "mp4", worker skips transcode, noonError) is fully_addressed.
createPixelVideoController.snapshotnow sniffs everyvideoentry:ftypat offset 4 passes; EBML (1a 45 df a3) is dropped as WebM; anything else (short, zeros, non-bytes) is dropped as not MP4. Each drop goes through the existingonErrorsink (a throwing sink still does not reject the snapshot). The report still builds without that member. That is the fail-closed path asked for, and it sits in the controller rather thanencodePixelVideoso a throwing encoder cannot take down bundle assembly.I re-read the gate against the intended host path (
video: { source }→ controller snapshot →reportSnapshots→ assembler). WebM fromnew MediaRecorder(stream)or a leftover webm/mjpegencodeno longer ships. Tests cover MP4 pass-through, WebM named in the message, mixed good+bad entries, non-bytes, and a throwing sink. Docs (electron.mdcontract paragraph,backend-beta-readiness.mdstruck item) and theencode/recorderFactoryJSDocs match.Ran
@bugsee/electronpixel-video-controller + display-video + e2e + launch-main + capture-state: 182 passed.Residual (accepted, not filed)
- The sniff is the container, not the codec: MJPEG-in-MP4 with a real
ftypwould still skip transcode. That is not the original mislabel.encodePixelVideostill byte-concatenates multiple unlaned payloads (invalid ISO-BMFF). Display lanes remain split.- Chromium
MediaRecorder.isTypeSupported('video/mp4;codecs=avc1')is still unverified; a host that cannot produce MP4 now gets a dropped video +onErrorinstead of a silent unplayable file.Overall
- Overall risk: Low
- Merge recommendation: Approve
- Most important issues to fix: none remaining
- Positive: The check is in the right place (controller snapshot, fail-closed, bundle still ships). Distinct error strings for WebM vs not-bytes vs no-ftyp. Design docs no longer claim the worker/viewer will see a mislabelled WebM.
Sent by Cursor Automation: Bugsee code review
There was a problem hiding this comment.
Review: export pixel video as MP4 (re-review at 2e2f82f)
The follow-up puts the container check on the live path. createPixelVideoController.snapshot sniffs ftyp at offset 4, drops WebM / short / wrong-box / non-bytes video entries, and reports through onError so the rest of the bundle still uploads. That is the right place for the gate: encodePixelVideo is an assembler encoder and a throw there would fail the whole report. The rename (video.mp4 → attrs.format: "mp4") plus this fail-closed filter is the Android-canonical contract without reopening the WebM-as-MP4 mislabel.
I re-traced host VideoCaptureSource.snapshot → controller filter → reportSnapshots extras → assembler fileEncoders.video. launchMain always wraps the opt-in source in the controller, so production pixel video cannot skip the sniff. Tests now use MP4-shaped fixtures (MP4_HEAD / MP4_FTYP) instead of shipping EBML under an .mp4 name.
Prior P1 — fully addressed
The previous finding (hard format: "mp4" with no byte check, so a default MediaRecorder WebM would skip transcode and not play) is fixed. WebM is named in the onError message; mixed snapshots keep the MP4 beside the dropped entries; a throwing sink still resolves [].
No new P0–P3
No remaining correctness, lifecycle, or mislabel bug on the production path.
Residual (not blocking)
encodePixelVideostill concatenates unlaned payloads. Two complete MP4s in one member is invalid ISO-BMFF. Display lanes are split and tested; a host that merges two sources without lanes would still hit it.- Chromium
MediaRecordervideo/mp4;codecs=avc1is still unverified (the PR’s own open question). That is now fail-closed: unsupported/default WebM is dropped withonError, not labelledmp4. - The sniff is container-only (
ftyp), not codec (avc1). A JPEG-only muxer that emits MJPEG-in-MP4 would pass; the seam JSDoc now says an H.264 encoder plus muxer is required.
Tests I actually ran
@bugsee/electronpixel-video-controller / display-video.integration / electron-e2e / launch-main / video-capture: 221 passed@bugsee/protocolconstants: 11 passed@bugsee/corebundle-assembler + bundle-stream-assembler: 117 passed
GitHub CI on this HEAD: Lint · Typecheck · Cycles · Coverage pass; E2E (node · bun · deno · real frameworks) pass; CodeQL pass.
Overall
- Overall risk: Low — opt-in feature, unpublished SDK, fail-closed on the mislabel that blocked the last review.
- Merge recommendation: Approve.
- Most important to fix: Nothing remaining on this PR. Confirm
MediaRecorderMP4 on the minimum Electron you ship before calling the pixel path done in product, not as a gate here. - Positive: Check is at snapshot (with
onError), not in the unguarded encoder. Distinct drop reasons (WebM vs noftypvs not bytes). Per-displayvideo.<n>.mp4+format: "mp4"still lines up (nthFileName/manifestEntryForType). Contract is written on the seams and inelectron.md; the stale “Electron video is WebM” backend item is marked resolved.
Sent by Cursor Automation: Bugsee code review


Refs #54.
What
DEFAULT_FILENAMES.videoisvideo.mp4(wasvideo.webm); per-display members arevideo.<n>.mp4. The manifest entry'sformatis derived from the extension, so it now saysmp4— the worker and viewer read it as the default H.264 MP4 and skip the WebM transcode. Android already writesvideo.mp4.electron.md,per-window-replay.md) updated; tests across protocol/core/node/electron now expect.mp4, and the electron e2e fake video starts with an MP4ftypbox.Contract change for hosts
The SDK ships no muxer: the host's
encode/MediaRecorderseam must now produce MP4 (H.264). Nothing validates the bytes, so a host that keeps producing WebM would ship a WebM labelled mp4.Open
MediaRecordercan emitvideo/mp4;codecs=avc1depends on the Electron/Chromium version — not verified here.Test plan
🤖 Generated with Claude Code