question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ffmpeg plugin: Increase TOTAL_MEMORY

See original GitHub issue

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: https://github.com/collab-project/videojs-record/issues/481). After downgrade during the conversion I started getting a “Cannot enlarge memory arrays.” error. I found the solution on (https://github.com/Kagami/ffmpeg.js/issues/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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thijstriemstracommented, Feb 4, 2021

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

0reactions
aphavichitrcommented, Feb 4, 2021

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

How do i get videojs.record 4.2.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible improvement to FFMPEG plugin - Development
This is a fantastic tool that allows easy loading of almost any video into ImageJ as a stack. However, because of the limited...
Read more >
Unlimited seeking during video transcoding - Diva Portal
High definition, long duration videos can contain complex scenes full of rich detail. As the details get richer and the duration grows, the....
Read more >
2014-August.txt - FFmpeg
I don't know why. but in C++ buffer size outbuf_size = 100000; was too small, so increase of buffer size solves the problem....
Read more >
Video Plugin crasht PicApport - Google Groups
to PicApport. I would definitely increase the memory size. java.runtime totalMemory=257mb maxMemory=477mb freeMemory=250mb processors=.
Read more >
Improving GPU Memory Oversubscription Performance
The loop count of the warp is determined by total number of warps and total memory allocated. Each warp of the kernel loops...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found