mp4box.js icon indicating copy to clipboard operation
mp4box.js copied to clipboard

May I ask how to solve the problem of continuous memory growth caused by parsing video streams in MP4BoxJS?

Open gitboyzcf opened this issue 2 years ago • 1 comments

I used webSocket to receive H265 video streaming and referenced the following code: 👇

https://github.com/w3c/webcodecs/tree/main/samples/audio-video-player ,

In this code, mp4boxjs is used to parse some encoded videos (h264, h265, vp8...).

But what I am transferring in webSocket is not video files, but infinite video streams, which will lead to an infinite increase in memory. I have tried many methods to solve this problem, but they have not been solved. May I ask how to properly release this memory.

gitboyzcf avatar Nov 13 '23 06:11 gitboyzcf

https://github.com/hughfenghen/WebAV/blob/main/packages/av-cliper/src/mp4-utils/index.ts#L421

Try to release used data

tracks.forEach(({ track, id }) => {
  file.releaseUsedSamples(id, track.samples.length)
  track.samples = []
})
file.mdats = []
file.moofs = []

hughfenghen avatar Jan 23 '24 14:01 hughfenghen