ffmpegwasm / ffmpegwasm/ffmpeg.wasm

Memory Access out of bounds when executing commands on a lot of files

Open
#704 3 comments 7 reactions 0 assignees View on GitHub
Dominant language
C
Stars
17.8k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

When using this library to get thumbnails for videos, I get a memory out of bounds error after 60 to 70 videos.
The exec args are : "-i input.mp4 -vf scale:71:-1 -frames:v 1 thumbnail.jpg"
It works well until 50 files but then I have an error and the Web Page crashed. The size of the files doesn't matter, the error happens after the same number of files.

My goal would be to use it on > 500 files at a time.

I saw that the library is spawning Web Workers to execute the command. But after executing, the Web Workers stays and is not deleted. Even when using the ffmpeg.terminate() function (which should kill everything), the Web Workers are still there and keep some memory with them (thus when spawning the next one, the browser doesn't have enough memory).

To reproduce, you just need a loop and execute the command > 80 times and it will crash at some point.

I would expect the terminate() function to actually kill all the Web Workers and free their memory OR to only spawn one Web Worker and use the same one to execute all the commands.

I use a Windows laptop that has 32GB of memory and I'm running ffmpeg.wasm in Chrome version 122.0.6261.112.

Thank you in advance!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.