WebAV
WebAV copied to clipboard
refactor: Update MP4Clip class to use fileToMP4Samples for parsing MP4 streams
关联的 issue:https://github.com/bilibili/WebAV/issues/129
尝试使用 OPFSToolFile 来分段解析 mp4 buffer 为 samples.
⚠️ No Changeset found
Latest commit: 8e0b654499d5c5189262c4ef17f35b5d54404ac7
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
添加一些测试用来说明内存问题得以解决:
- 测试视频:
- 3.5GB 的电影 《星际穿越》 (🚫🚫🚫说明该文件只用作学习交流用,不可用作其他商业用途)
- 其他大小的视频可以用 ffmpeg 裁剪出来
- 测试环境:
- Google Chrome Version 126.0.6478.183 (Official Build) (arm64)
- MacBook Pro 16G Apple M1(14.5 (23F79))
- 测试页面: http://localhost:6066/decode-media.html
before(main 分支)
| 视频大小 | 结果 |
|---|---|
| 3.5GB | 整个电脑 crush 崩溃了 |
| 1.3GB | 在视频解析阶段进程会被卡死,等待一段时间之后能正常播放视频 |
| 87.7MB | 功能正常使用 |
after(本 PR 代码)
| 视频大小 | 结果 |
|---|---|
| 3.5GB | 解析进度比较慢,但是能浏览器和操作系统不会被卡死 等待很久之后,视频能够播放出来,但是画面比较卡顿 |
| 1.3GB | 功能正常使用 |
| 87.7MB | 功能正常使用 |
## 内存泄露(这部分的内容其实与本 PR 无关,先纪录下来问题,未来会在其他 PR 修复)
在测试的过程中,有监听浏览器内存占用情况。发现会有内存泄露的问题:
- 初始页面:
- 视频播放:
- 视频播放一段时间:
- 视频播放完毕:
performance 抓取数据
内存快照
注释掉 audioFrameFinder 代码内存占用立马降低 10+ 倍
@wendraw 感谢你的贡献,我在 #291 实现了优先解析 moov,分段解析 mdat box,避免解析阶段占用过大内存。 有空的话,可以帮忙 review 代码。
@wendraw 感谢你的贡献,我在 #291 实现了优先解析 moov,分段解析 mdat box,避免解析阶段占用过大内存。 有空的话,可以帮忙 review 代码。
已 review 请查收