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

Out of memory when trying to trim a video

Open mrcatman opened this issue 5 years ago • 5 comments

I'm trying to trim a H264 video which comes from an Ajax request. FFMpeg is inside a worker (ffmpeg-worker-mp4.js):

ffmpeg.postMessage({
    type: 'run',
    arguments: [
      '-i', 'video.mp4',
	  '-vcodec', 'h264',
	  '-acodec', 'copy',
	  '-ss', '39.2',
	'-to', '74.2',
       '-strict', 'experimental', 'test2.mp4'
     ],
    MEMFS: [
        {
            data: video,
            name: 'video.mp4'
        }
     ]
    });

But after 10 seconds of starting the process closes with an error:

app.js?1592332511:4050 frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
app.js?1592332511:4050 frame=    5 fps=0.7 q=0.0 size=       0kB time=00:00:00.13 bitrate=   2.8kbits/s dup=1 drop=0 speed=0.0184x    
app.js?1592332511:4046 OOM
app.js?1592332511:4050 OOM
app.js?1592332511:4050 exception thrown: abort(OOM). Build with -s ASSERTIONS=1 for more info.

Tried to encode the video with the WebM version, it does not give any errors, but the process is very slow. Is it possible to do something with the MP4 version?

mrcatman avatar Jun 16 '20 18:06 mrcatman

Also: the video itself is just ~20MB, and the increasing of TOTAL_MEMORY did not help.

mrcatman avatar Jun 16 '20 18:06 mrcatman

Try putting -ss before the -i flag and then using -t <how_many_seconds> instead of -to

samelie avatar Sep 04 '20 22:09 samelie

did you ever solve this? I get OOM expections when trying to encode even the smallest video (a few seconds)

olelivalife avatar Jan 06 '21 14:01 olelivalife

@olelivalife same here. always get an OOM exception regardless of length

AxelRothe avatar Feb 18 '21 13:02 AxelRothe

I'm having the same issue.

BrunoQuaresma avatar Dec 05 '21 16:12 BrunoQuaresma