Skip to content

Out of Memory when creating an Image Slideshow #107

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

Closed
nicolasdeory opened this issue Apr 30, 2020 · 8 comments
Closed

Out of Memory when creating an Image Slideshow #107

nicolasdeory opened this issue Apr 30, 2020 · 8 comments

Comments

@nicolasdeory
Copy link

nicolasdeory commented Apr 30, 2020

I'm trying to create an image slideshow using the following arguments:

-i audioTrack.mp3 -framerate 1/3 -pattern_type glob -i /photofolder/*.jpg 
-tune stillimage -profile:v baseline -vb 100K -c:v libx264 -pix_fmt yuv420p 
-shortest -preset ultrafast

I have the images stored in WORKERFS. As soon as I load it with more than 3 small images, or even 1 that weighs 3MB, I get an OOM exception. The audioTrack file weighs 6.8MB.

Why does the program have such a small memory heap?

@nicolasdeory nicolasdeory changed the title Out of Memory creating an Image Slideshow Out of Memory when creating an Image Slideshow Apr 30, 2020
@Kagami
Copy link
Owner

Kagami commented Apr 30, 2020

I didn't have problems with ultrafast preset. Try to increase TOTAL_MEMORY though.

@nicolasdeory
Copy link
Author

This is what I have:

worker.postMessage({
                    type: "run",
                    TOTAL_MEMORY: 256 * 1024 * 1024, 
                    //MEMFS: blobsArray,
                    mounts: [{
                        type: "WORKERFS",
                        mountpoint: "/test",
                        opts: {
                            blobs: blobsArray
                            }
                        }],
                    arguments: arg.split(" ")
                });

@nicolasdeory
Copy link
Author

nicolasdeory commented Apr 30, 2020

My use case is loading at least 20 images via XHR, save them to blobs, and pass them to FFmpeg to make the slideshow. So they are loaded in memory, even if FFmpeg doesn't use them.

@nicolasdeory
Copy link
Author

Heavily downscaling the source images helped mitigate the issue.

@Kagami
Copy link
Owner

Kagami commented May 1, 2020

What resolution was it originally?

@tpetry
Copy link
Contributor

tpetry commented May 1, 2020

The problem is that ffmpeg is not really designed for memory efficiency. In your case frmpeg loads all images to the memory and then will do your requested operation, so you easily exceed the memory limit.

A wasm build (#10) may solve the problem because the memory is infinitely growable. At least until the browser decides you had enough. The actual build has a defined maximum limit set at build time.

@nicolasdeory
Copy link
Author

nicolasdeory commented May 1, 2020

@Kagami The images were 2-4MB 5000x3000 JPEG DSLR images, I didn't notice that they had such a high resolution. I downscaled them to 150KB 1280x720 and it seems to work with ~60 images. I haven't tried more yet. However, the memory limit is still extremely small, and as soon as I add any more complicated effects via filter-complex or vf/af, I run out of memory.

@tpetry Is building for Wasm straight-forward enough? I can try building for Wasm but I'm unfamiliar with the build workflow. Or at least increase the maximum memory at build time, because I believe the limit is around 64MB, because the heap almost never reaches that size. If I had a bit more leeway I wouldn't really need anything else, plus I don't want to break compatibility with mobile browsers, since right now it works perfectly on Safari.

@Kagami
Copy link
Owner

Kagami commented May 1, 2020

Closing in favor of #10.

@Kagami Kagami closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants