Files
shafeq 01f61dfada fix(export): return temp path from buffer-mode FFmpeg muxer (>2 GiB)
Exports of recordings whose muxed output exceeds 2 GiB failed with
RangeError [ERR_FS_FILE_TOO_LARGE]: Node's fs.readFile rejects files
larger than kIoMaxLength (2 ** 31 - 1). The legacy export pipeline hit
this in muxExportedVideoAudioBuffer, which called
  await fs.readFile(finalized.outputPath)
to ship the muxed bytes back to the renderer.

Mirror the path-based contract that mux-exported-video-audio-from-path
already uses:

- muxExportedVideoAudioBuffer now returns { outputPath, metrics } and
  collects byte size via fs.stat instead of fs.readFile. The unmuxed
  intermediate is still cleaned up; the muxed output is left for the
  IPC handler to register and the renderer to finalize.
- The mux-exported-video-audio IPC handler registers the muxed output
  via registerOwnedExportPath and returns { tempPath, metrics }.
- preload.ts and electron-env.d.ts: tempPath replaces data in the
  renderer-facing return type.
- videoExporter.ts and modernVideoExporter.ts (the
  finalizeExportWithFfmpegAudio fallback paths) now return
  { tempFilePath } so VideoEditor's existing finalize-exported-video
  flow handles the move — the same path the modern stream-mode export
  already takes.

The renderer already preferred tempFilePath over blob in
VideoEditor.tsx for MP4 saves (with the explicit comment "avoids ever
allocating a multi-GiB ArrayBuffer in the renderer"), so this just
removes the buffer-mode regression for large legacy exports.

Adds electron/ipc/export/native-video.test.ts asserting the new
contract: muxExportedVideoAudioBuffer returns a path, never calls
fs.readFile, and still records muxedVideoBytes via stat.

Closes #380
2026-05-02 09:48:05 +08:00
..