Repository navigation
perf(aws-lambda): build the final mp4 inside S3 with its index up front - #5805
Merged
miguel-heygen merged 1 commit intoOct 18, 2026
Merged
Conversation
This was referenced Oct 17, 2026
miguel-heygen
marked this pull request as ready for review
October 17, 2026 17:36
The Lambda plan asks chunks to carry their audio. Assemble writes the faststart header as part 1 of a multipart upload and copies each chunk's mdat payload with UploadPartCopy, so the video bytes never pass through the function; any failure aborts the upload.
miguel-heygen
force-pushed
the
cloudrender/s3-faststart-stitch
branch
from
October 17, 2026 17:50
26c28d7 to
0a60dee
Compare
miguel-heygen
changed the base branch from
cloudrender/chunk-audio
to
cloudrender/mp4-index
October 17, 2026 17:51
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5812 (the MP4 index builder), which is stacked on #5803 (chunks carry their audio). This is the AWS half: the final mp4 is assembled inside S3 as a regular faststart file, so browsers start it from a URL.
What changed
On the AWS Lambda path,
format: "mp4"renders (withoutcfr) now plan withchunksCarryAudio. Assemble builds a regular faststart MP4 inside S3:ftyp, onemoovthat indexes every sample, then one 64-bitmdat.stitchMp4InS3reads each chunk'sftypandmoovwith two small ranged GETs and builds the header with perf(cloud): assemble chunk output with a single faststart index #5812'sbuildStitchedHeader.UploadPartCopyof one chunk'smdatbyte range, so those bytes never pass through the function.s3:AbortMultipartUpload, whichS3CrudPolicylacks; the snapshot test pins it.chunksAreStitchedMp4,buildStitchedHeader,readMp4LayoutandmuxChunkWithAudioare exported from@hyperframes/producer/distributedfor this package.What I measured
Locally:
s3Stitch.test.ts:ffprobe -v errorsilent, boxesftyp, moov, mdat, 91 frames and all audio packets. Frames, PCM and stream durations equal today'sassemble(), and the localassemble()output is byte-identical to the S3 output.handler.test.ts: a plan whose chunks carry audio assembles through S3 and never calls the local join.tsc(producer, engine, aws-lambda), oxlint, oxfmt,fallow audit(new-only gate) and the comment checks pass.On AWS: a 30-minute 1080p30 benchmark, on the same fixture as main's baseline with inputs pinned by sha256. Deployed with
--concurrency 300and rendered with--max-parallel-chunks 225(225 chunks of 8 s). Measured on the same code before it was split into this stack (#5803, #5812, this PR). The split changed only file layout, a flag name and the in-chunk sample count check, which now uses ffprobe. I have not re-run AWS on the split branches.-movflags +faststart, and "fragmented" is the same streams as fragmented MP4.ffprobe -v errorsilent. Boxes:ftyp, a 1.99 MBmoovat the front, onemdat.What I did not exercise