Kagami / ffmpeg.js

Port of FFmpeg with Emscripten
Other
3.28k stars 332 forks source link

Out of memory when trying to trim a video #117

Open mrcatman opened 4 years ago

mrcatman commented 4 years ago

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 commented 4 years ago

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

samelie commented 4 years ago

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

olelivalife commented 3 years ago

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

AxelRothe commented 3 years ago

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

BrunoQuaresma commented 2 years ago

I'm having the same issue.