refactor(mux): streaming writes, memory reduction, and E2E test suite#508
Open
refactor(mux): streaming writes, memory reduction, and E2E test suite#508
Conversation
Sequential load-write-release pattern in streamToMp4Blob avoids holding both video and audio buffers simultaneously. Replaced Blob+fetchFile with direct Uint8Array writes to FFmpeg FS, eliminating redundant copies. Added blob URL revocation via downloads.onChanged listener.
Replace the bash verify-muxing.sh with TypeScript E2E tests that call the real writeMediaToFFmpegFS and muxExec through a host ffmpeg adapter, producing real output files verified by ffprobe snapshots (sha256, size, duration, stream details). Tests auto-skip on CI where ffmpeg is absent.
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.
Summary
Muxing pipeline refactor
streamToMp4Blob: loads video data, writes to FFmpeg FS, releases, then does the same for audio — never holding both in memory simultaneouslyBlob+fetchFilewith directUint8Arraywrites to FFmpeg FS, eliminating a redundant full-size copy per media streamdownloads.onChangedlistener — frees output blob memory after download completes or is interruptedwriteMediaToFFmpegFSandmuxExecfrommuxStreamsfor testability;muxStreamsremains as a backward-compatible wrapperBug fixes
-map 0→-map 0:v -map 0:a?) — prevents data/metadata streams from leaking into output (Save = 0 Bytes with 5.4.0 on Firefox #509)-shortestonly with separate video + audio — was previously always added, causing truncation on single-input muxesmuxExecnow throws on non-zero ffmpeg exit codes with a descriptive messageTest suite
ffmpeg-muxer.test.ts): arg construction, cleanup, error handling for all mux pathsmux-pipeline.integration.test.ts): IndexedDB → FFmpeg mock pipeline with real TS fixturesmux-pipeline-e2e.test.ts): real ffmpeg via host adapter, output verified by ffprobe snapshots (sha256, byte size, duration, codec, dimensions, channels, frame count). Auto-skips on CI. Output files saved tofixtures/e2e-output/for manual inspection.Closes #492 #509 #496
Related: #496, #204, #258, #509
Test plan