Skip to content

media-export: stream input and output instead of whole-file Blob + BufferTarget (remaining #405 baseline) #419

Description

@maboa

Follow-up to #405. The time-stretch no longer buffers the decoded timeline (stream-stretch.js), but the export baseline still holds the whole source and the whole encoded output in memory regardless of rate:

  • makeInput fetches the entire source into a Blob before mediabunny reads it (~4–5 GB for a 2 h 1080p file).
  • BufferTarget accumulates the full encoded output in one ArrayBuffer, and new Blob([output.target.buffer]) then duplicates it (~2.3 GB + ~2.3 GB transient for the same export).

Proposed direction

  • Output: offer mediabunny's StreamTarget backed by the File System Access API (showSaveFilePicker) when available, falling back to BufferTarget + download elsewhere (Safari/Firefox). This is a UX change — the save location is chosen at export start rather than on download — which is why it was split out of media-export: time-stretch path buffers the entire decoded PCM timeline in RAM — multi-GB, OOM on long media #405 rather than bundled.
  • Input: for http(s) sources, hand mediabunny a UrlSource/streaming source instead of pre-fetching a Blob; blob:/data: URLs (local files restored from IndexedDB) can stay as they are, since the bytes already live in memory.

Together these drop peak memory for a long 1× export from ~3× file size to roughly the demuxer/encoder working set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions