feat(normalize, author): the page's build moves an mp4's index to the front
Merged
AL
3d ago+289+289+012345678901234567890123456789-154-154-012345678901234567890123456789
Part of #218: item 5, "The build page moves an mp4's index to the front". Item 4 is #258; item 6 and the open question stay in #218.
What changes
- The normalizer's remux plan moves into
./mp4asfaststartPlan(read, size), onUint8ArrayandDataViewrather thanBuffer, likemp4Infobeside it. It returns{ status, detail, pieces, size }: each piece a range of the file or the rewritten index. Only the index is read whole. mp4-faststart.mjs'splanFaststart(file, base, size)is now a wrapper: the file's bytes in, the ranges shifted bybase. The remux exists once, andnormalizeArchiveis unchanged.- The page's build lays out an mp4 or an m4a with its index first, as Node's build does through the normalizer. The file is a
Blobof the given file's slices and the rewritten index, so no byte of the media is copied, and its CRC is that of what is stored. Every stored file is asked of the plan, which tells an ISO media file by its first eight bytes and leaves any other file, and one with its index first already, as given: the page keeps no list of extensions beside the normalizer's. - An index of containers nested deeper than a real one is left alone. The walk through
moovwent into every container, so a crafted file of a hundred thousandtrakatoms inside each other ended it with aRangeError, in the normalizer too, before this change. It now stops eight deep (a real index nests four) and the file comes backskipped.
Before, a phone's video built on the build page could start playing only once it had arrived whole.
Release order: the normalizer first, and the publish check holds it
The page build imports faststartPlan by name, and npm's record of a version lists entries, not what they export. So check-pack-published.mjs now refuses to publish the author while packages/normalize is below 1.5.0, the first version with it:
- normalize 1.5.0 (minor, new export);
- then the author, whose
workspace:^publishes as^1.5.0, which the same check then finds on npm.
Run today, with the normalizer at 1.4.1, the check stops with that instruction. I have not bumped anything.
Tests
- normalize: 35, two new.
faststartPlanon bytes in memory gives the same bytes as the file path, and leaves the bytes it read unchanged; a faststart file and a web page come back as one whole-file piece. The crafted index isskipped, and one nested as a real one is moved. - author: 280 Node and 2 Chromium tests. The page test now unzips the built package: the clip is stored, the same size,
moovbeforemdat, and its CRC checks out on read. - embed 83, skills 82, type checks of normalize and author.
Docs
The author README ("In a page"), the normalizer README (faststartPlan), docs/compatibility.md, design/author.md, design/normalize.md and design/layout.md.