mp4-muxer: "Array buffer allocation failed" when finalizing with FileSystemWritableFileStreamTargetWriter

Hi,

So I’m trying to export a large file (around 1.5GB), and using FileSystemWritableFileStreamTargetWriter, but it crashes right upon trying to call muxer.finalize().

mp4-muxer.mjs:714 Uncaught (in promise) RangeError: Array buffer allocation failed
    at new ArrayBuffer (<anonymous>)
    at new Uint8Array (<anonymous>)
    at FileSystemWritableFileStreamTargetWriter.createChunk_fn (mp4-muxer.mjs:714:1)
    at FileSystemWritableFileStreamTargetWriter.writeDataIntoChunks_fn (mp4-muxer.mjs:665:1)
    at FileSystemWritableFileStreamTargetWriter.writeDataIntoChunks_fn (mp4-muxer.mjs:685:1)
    at FileSystemWritableFileStreamTargetWriter.write (mp4-muxer.mjs:650:1)
    at Muxer.finalize (mp4-muxer.mjs:849:1)

Using the latest version 5.1.5, but it did the same in 3.x that I had in my proejct previously.

If this helps this is how I initialize the muxer:

this.muxer = new Muxer({
            fastStart: 'in-memory',
            target: new FileSystemWritableFileStreamTarget(stream),
            video: {
                codec: 'avc',
                width: this.w,
                height: this.h
            },
            audio: {
                codec: 'aac',
                sampleRate: this.audioSampleRate,
                numberOfChannels: this.audioNumberOfChannels
            },
            firstTimestampBehavior: 'offset'
        });

It works well while I keep adding the frames, but crashes upon “finalize”. It works fine for smaller files.

Any help would be appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Alright man. I can just tell you personally that this project started with me needing to write large files (~7 GB), and it did work just fine with this lib. But you never know when shit might regress… Anyway, I’ll make sure to keep testing large files in the future.

yes, I’ve implemented indexedDB and it’s working fine, even with gigabytes of files stored. Another option is to use localstorage, but it requires base64 encoding/decoding. I can’t find much info about this 4GB limitation, But it seems to be a per tab limit. I will try to find out why it’s stopping at 2gb, there must be something else eating the memory.