Skip to content

feat(video): port the buffered video encapsulation layer - #581

Merged
awatson1978 merged 2 commits into
release/1.0-beta-videofrom
video-pr3-encapsulated
Oct 2, 2026
Merged

awatson1978 merged 2 commits into
release/1.0-beta-videofrom
video-pr3-encapsulated

Conversation

@awatson1978

Copy link
Copy Markdown
Collaborator

This ports the buffered video encapsulation layer — no findings live here, so it's the small one of the wave. Supplement 225 lets an MP4's H.264 stream travel inside a Video Photographic Image instance verbatim: the pixel data fragments are consecutive byte ranges of the one stream, so extraction is concatenation and the round trip is byte-identical. Three functions, mirroring the shape of encapsulatedPdf: buildVideoDataset makes the naturalized dataset shell (XC modality, CineRate/FrameTime from the measured rate, the YBR_PARTIAL_420 8-bit geometry PS3.5 §8.2.6 mandates for MPEG-4 AVC syntaxes, and the (7FE0,0003) Encapsulated Pixel Data Value Total Length as a BigInt — UV is a uint64); encapsulateVideo splits the MP4 into fragment-sized exact ArrayBuffer slices (default 256 MiB, validated even 32-bit per PS3.5 §A.4); and extractEncapsulatedVideo concatenates fragments and truncates to the declared total length, which is what lets the Part 10 writer's pad byte on an odd-length final fragment drop cleanly on extraction.

On provenance: encapsulatedVideo.js and its 8-test suite are verbatim ports from the v2 branch, isolated in their own commit with one mechanical adjustment — DicomMetaDictionary and isVideoTransferSyntax now come from @dcmjs-org/core instead of relative paths. The hand-written remainder is the ~30 lines of index wiring in the second commit, which exports only the video half of v2's encapsulated index; the PDF half (encapsulatedPdf) belongs to the media wave, not this package.

The test suite pins the element list against the Supplement 225 reference fixture's dataset (the large-files build_dicom_video.py oracle), exercises fresh-UID minting and overrides, the ffmpeg-corrective error for unsupported codecs, fragment-size validation, the byte-identical round trip over an odd-length stream with a simulated writer pad byte, the declared-length-absent fallback, and the corrective rejection of a non-video dataset. Fifty tests in the package overall, all green, still no binary fixtures.

🤖 Generated with Claude Code

awatson1978 and others added 2 commits October 2, 2026 13:40
Verbatim from v2.0-development src/encapsulated/encapsulatedVideo.js and
its 8-test suite, with one mechanical adjustment for the package
boundary: DicomMetaDictionary and isVideoTransferSyntax now come from
@dcmjs-org/core instead of relative paths. buildVideoDataset shapes the
Supplement 225 Video Photographic Image shell (XC modality, cine timing,
the (7FE0,0003) uint64 total length as a BigInt), encapsulateVideo
splits the MP4 into fragment-sized exact ArrayBuffer slices, and
extractEncapsulatedVideo concatenates fragments and truncates to the
declared length so the odd-fragment pad byte drops on extraction.

Co-Authored-By: Claude Fable 5 <[email protected]>
The video half of v2's encapsulated index only — the PDF half
(encapsulatedPdf) belongs to the media wave.

Co-Authored-By: Claude Fable 5 <[email protected]>
@awatson1978
awatson1978 merged commit 34cec2b into release/1.0-beta-video Oct 2, 2026
8 checks passed
@awatson1978
awatson1978 deleted the video-pr3-encapsulated branch October 2, 2026 18:50
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.

1 participant