ffmpeg.wasm
ffmpeg.wasm copied to clipboard
Out of Memory Issues while Transcoding
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
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;
me too! Memory always Out of Memory when file size > 100MB
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.
2-3 gigs
It has nothing to do with react, trying still happens in HTML..
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]
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.
Also having out of memory errors with 890kb file on Firefox: https://github.com/ffmpegwasm/ffmpeg.wasm/issues/111
the same problem on 0.9.7
I can confirm that the problem exists on 0.10.1 as well.
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:
- https://ffmpegwasm.netlify.app/#Demo in iOS Safari, click the "Upload audio/video file" and choose any supported file format.
- The
SharedArrayBuffer
is only supported on the newest iOS 15.2. so make sure it is the case. - The error should appear in console log.
@IvanSivak I am getting the same issue as you for Safari 15.2 on my iPhone.
still same problem exist
still in fmpeg.wasm v0.11.6