Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg plugin: Increase TOTAL_MEMORY #539

Closed
aphavichitr opened this issue Jan 27, 2021 · 5 comments
Closed

ffmpeg plugin: Increase TOTAL_MEMORY #539

aphavichitr opened this issue Jan 27, 2021 · 5 comments

Comments

@aphavichitr
Copy link

aphavichitr commented Jan 27, 2021

Description

I'm trying to convert my videos to mp4 using the ffmpeg.js plugin. I had to downgrade ffmpeg.js to an earlier version, 3.1.9001 otherwise I would get a OOM error in chrome (as documented in: #481). After downgrade during the conversion I started getting a "Cannot enlarge memory arrays." error. I found the solution on (Kagami/ffmpeg.js#9), which requires the TOTAL_MEMORY to be increased and passed in. Is there a way to do this?

Steps to reproduce

Record a video with the following conversion settings:

convertEngine: 'ffmpeg.js',
convertOptions: [
  '-f',
  'mp4',
  '-codec:a',
  'aac',
  '-codec:v',
  'libx264',
],
pluginLibraryOptions: {
  outputType: 'video/mp4',
},
convertWorkerURL: '/ffmpeg-worker-mp4.js',`

Results

Expected

Should be able to convert video if memory is increased.

Actual

Failed to convert due to lack of memory.

Error output

Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 67108864, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 
ffmpeg-worker-mp4.js:25 Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 67108864, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 
Ua.e.printErr.e.printErr @ ffmpeg-worker-mp4.js:25
A @ ffmpeg-worker-mp4.js:19
qa @ ffmpeg-worker-mp4.js:30
Ba @ ffmpeg-worker-mp4.js:15
B_a @ ffmpeg-worker-mp4.js:3503
I_a @ ffmpeg-worker-mp4.js:3503
H_a @ ffmpeg-worker-mp4.js:3503
cRa @ ffmpeg-worker-mp4.js:3492
KRa @ ffmpeg-worker-mp4.js:3501
HWa @ ffmpeg-worker-mp4.js:3503
GY @ ffmpeg-worker-mp4.js:3495
Q2 @ ffmpeg-worker-mp4.js:3479
lf @ ffmpeg-worker-mp4.js:3487
bf @ ffmpeg-worker-mp4.js:3487
Oi @ ffmpeg-worker-mp4.js:3487
Ye @ ffmpeg-worker-mp4.js:3487
Ve @ ffmpeg-worker-mp4.js:3487
Ua.e.callMain.e.sf @ ffmpeg-worker-mp4.js:3514
b @ ffmpeg-worker-mp4.js:17
Oa @ ffmpeg-worker-mp4.js:18
Ua @ ffmpeg-worker-mp4.js:3515
self.onmessage @ ffmpeg-worker-mp4.js:3517
ffmpeg-worker-mp4.js:3515 Uncaught abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 67108864, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ") at Error
    at ya (http://localhost:3000/ffmpeg-worker-mp4.js:9:262)
    at A (http://localhost:3000/ffmpeg-worker-mp4.js:19:80)
    at Function.qa [as Bc] (http://localhost:3000/ffmpeg-worker-mp4.js:30:54)
    at Ba (http://localhost:3000/ffmpeg-worker-mp4.js:15:216)
    at B_a (http://localhost:3000/ffmpeg-worker-mp4.js:3502:211366)
    at I_a (http://localhost:3000/ffmpeg-worker-mp4.js:3502:229696)
    at H_a (http://localhost:3000/ffmpeg-worker-mp4.js:3502:229450)
    at cRa (http://localhost:3000/ffmpeg-worker-mp4.js:3491:359067)
    at KRa (http://localhost:3000/ffmpeg-worker-mp4.js:3500:27449)
    at HWa (http://localhost:3000/ffmpeg-worker-mp4.js:3502:40819)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs

4.1.1

ffmpeg.js

3.1.9001

browsers

Chrome

OSes

Mac

@thijstriemstra
Copy link
Member

@aphavichitr what version of chrome and macos?

@thijstriemstra thijstriemstra changed the title Increase TOTAL_MEMORY for ffmpeg plugin ffmpeg plugin: Increase TOTAL_MEMORY Jan 30, 2021
@aphavichitr
Copy link
Author

I'm on Chrome 88.0.4324.96 and MacOS 10.15.6

@thijstriemstra
Copy link
Member

thijstriemstra commented Jan 31, 2021

TOTAL_MEMORY is used during compilation of ffmpeg.js, see https://github.com/Kagami/ffmpeg.js/blob/master/Makefile#L227 You need to build it from scratch in order to change the total memory.

I would try ffmpeg.wasm plugin in videojs-record 4.2.0 instead.

@aphavichitr
Copy link
Author

I would try ffmpeg.wasm plugin in videojs-record 4.2.0 instead.

How do i get videojs.record 4.2.0?

@thijstriemstra
Copy link
Member

How do i get videojs.record 4.2.0?

It's not released yet (at time of this writing) but you can install master branch using: npm install https://github.com/collab-project/videojs-record.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants