gpac / mp4box.js

JavaScript version of GPAC's MP4Box tool
https://gpac.github.io/mp4box.js/
BSD 3-Clause "New" or "Revised" License
1.95k stars 330 forks source link

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

Open gitboyzcf opened 10 months ago

gitboyzcf commented 10 months ago

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.

hughfenghen commented 8 months ago

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 = []