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

Out of Memory Issues while Transcoding

Open wuharvey opened this issue 4 years ago • 13 comments

Describe the bug Cloned the react demo and modified to select videos from filesystem.

To Reproduce I selected an 2mb .MOV file and received this error in the console:

ffmpeg-core.js:1 Pthread aborting at Error
    at abort (https://unpkg.com/@ffmpeg/[email protected]/ffmpeg-core.js:1:17294)
    at abortOnCannotGrowMemory (https://unpkg.com/@ffmpeg/[email protected]/ffmpeg-core.js:1:25109052)
    at _emscripten_resize_heap (https://unpkg.com/@ffmpeg/[email protected]/ffmpeg-core.js:1:25109113)
    at <anonymous>:wasm-function[1681]:0xf9ff8
    at _e (<anonymous>:wasm-function[588]:0x274d7)
    at <anonymous>:wasm-function[4855]:0x405053
    at $e (<anonymous>:wasm-function[1682]:0xfa033)
    at <anonymous>:wasm-function[380]:0x11346
    at <anonymous>:wasm-function[2804]:0x202ad3
    at <anonymous>:wasm-function[14466]:0xb781d2

Desktop (please complete the following information): Chrome, Mac OS

wuharvey avatar Jul 19 '20 02:07 wuharvey

Modified app.js:

import React, { useState, useCallback } from 'react';
import { createFFmpeg } from '@ffmpeg/ffmpeg';
import './App.css';

function App() {
  const [videoSrc, setVideoSrc] = useState('');
  const [message, setMessage] = useState('Click Start to transcode');
  const ffmpeg = createFFmpeg({
    log: true,
  });
  const doTranscode = useCallback(
   async () => {
    setMessage('Loading ffmpeg-core.js');
    await ffmpeg.load();
    setMessage('Start transcoding');
    await ffmpeg.write('test.avi', videoSrc);
    await ffmpeg.transcode('test.avi', 'test.mp4');
    setMessage('Complete transcoding');
    const data = ffmpeg.read('test.mp4');
    setVideoSrc(URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' })));
  }, [videoSrc]);
  const uploadFile = (e) => {setVideoSrc(e.target.files[0])};
  return (
    <div className="App">
      <p/>
      <video src={videoSrc} controls></video><br/>
      <button onClick={doTranscode}>Start</button>
      <input type="file" id="uploader" onChange={uploadFile}/>
      <p>{message}</p>
    </div>
  );
}

export default App;

wuharvey avatar Jul 19 '20 03:07 wuharvey

me too! Memory always Out of Memory when file size > 100MB

veeking avatar Jul 31 '20 04:07 veeking

I think this is an error with react, I get this error occasionally on React when using the library but at https://videotranscode.space/ (build-in Svelte) we have had people upload like 2-3 gigs of content and it works fine.

CryogenicPlanet avatar Aug 04 '20 07:08 CryogenicPlanet

2-3 gigs

It has nothing to do with react, trying still happens in HTML..

veeking avatar Aug 04 '20 07:08 veeking

try cmd -i input.mp4 -c:v libx264 -preset fast -crf 28 -c:a copy ouput.mp4, You can see the out of Memory Issues [email protected]

veeking avatar Aug 04 '20 07:08 veeking

Not sure if the same issue is still there in the latest version (0.9.3), please kindly give it a try and let me know the result. Let's keep this issue open for some time.

jeromewu avatar Nov 04 '20 01:11 jeromewu

Also having out of memory errors with 890kb file on Firefox: https://github.com/ffmpegwasm/ffmpeg.wasm/issues/111

thijstriemstra avatar Nov 14 '20 22:11 thijstriemstra

the same problem on 0.9.7

Felixcong avatar Feb 20 '21 09:02 Felixcong

I can confirm that the problem exists on 0.10.1 as well.

eulertour avatar Aug 28 '21 01:08 eulertour

I'm also having the issue (@ffmpeg/core: 0.10.0 and @ffmpeg/ffmpeg: 0.10.1):

[Error] Unhandled Promise Rejection: RangeError: Out of memory
	dispatchException (2.549adfcd.chunk.js:2:273751)
	(anonymous function) (2.549adfcd.chunk.js:2:269979)
	t (2.549adfcd.chunk.js:2:283360)
	s (2.549adfcd.chunk.js:2:283600)
	promiseReactionJob

This issue happens only on my iPhone, Safari 15.2. The selected file is an audio file: MPEG-4, 192 kb/s, 48.0 kHz, 2 channels, AAC LC. It is only 467kb big (20s).

This happens only on a mobile. On Macbook Safari 15.2. everything works fine.

To reproduce:

  1. https://ffmpegwasm.netlify.app/#Demo in iOS Safari, click the "Upload audio/video file" and choose any supported file format.
  2. The SharedArrayBuffer is only supported on the newest iOS 15.2. so make sure it is the case.
  3. The error should appear in console log.

IvanSivak avatar Jan 06 '22 15:01 IvanSivak

@IvanSivak I am getting the same issue as you for Safari 15.2 on my iPhone.

haroonabp avatar Jan 11 '22 20:01 haroonabp

still same problem exist

umarnsisar021 avatar Apr 09 '23 22:04 umarnsisar021

still in fmpeg.wasm v0.11.6

anazh avatar Sep 28 '23 02:09 anazh