ffmpeg.js icon indicating copy to clipboard operation
ffmpeg.js copied to clipboard

MP4 Encoding returns OOM

Open videoinu opened this issue 4 years ago • 4 comments

Hey, re-encoding a very simple video of few seconds with no audio from vp8 webm to h264 mp4 keeps running out of memory.

OOM
exception thrown: abort(OOM). Build with -s ASSERTIONS=1 for more info.

This is on Firefox, so maybe something related to asm.js?

videoinu avatar May 22 '20 05:05 videoinu

Try using the ultrafast preset, and small files if possible.

nicolasdeory avatar May 22 '20 12:05 nicolasdeory

Preset and small files indeed help, although it would be nice to support potentially larger source videos, if needed

videoinu avatar May 25 '20 05:05 videoinu

would compiling with a higher TOTAL_MEMORY https://github.com/Kagami/ffmpeg.js/blob/master/Makefile#L227 help here?

AlexVestin avatar Jun 01 '20 10:06 AlexVestin

@videoinu Did you ever get any further with this? The ultrafast preset makes the conversion possible but it's quite slow. Running in WebWorker took me 374s to encode a 60s video...

Any tips on how to improve this is much welcome 👍

worker.postMessage({
    type: 'run',
    MEMFS: [
      {
        name: 'test.webm',
        data: evt.target.result,
      },
    ],
    arguments: [
      '-r',
      '60',
      '-i',
      'test.webm',
      '-c:v',
      'libx264',
      '-aspect',
      '16/9',
      '-crf',
      '1',
      '-preset',
      'ultrafast',
      '-pix_fmt',
      'yuv420p',
      '-vb',
      '20M',
      'test.mp4',
    ],
  })
}

olelivalife avatar Jan 06 '21 15:01 olelivalife