-
Notifications
You must be signed in to change notification settings - Fork 110
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
Refactor/parse mp4 #291
base: main
Are you sure you want to change the base?
Refactor/parse mp4 #291
Conversation
🦋 Changeset detectedLatest commit: ef8605b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (box == null) break; | ||
|
||
if (box.name === 'moof') isFMP4 = true; | ||
if (box.name === 'mdat' && box.data == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
box.data 是什么情况下没有数据呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了一下 getNextBox 返回的 mdat 类型 box 就是把 data 去掉的,那么下面的 if (box.data != null) 分支是不是永远不会执行?或者说 mp4boxFile 会重复解析?
let remainSize = box.size; | ||
while (remainSize > 0) { | ||
// 非 fMP4 文件的 mdat box 非常大,一次最多读取 30MB,避免内存占用过大 | ||
const chunkSize = Math.min(remainSize, 30 * 1024 * 1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 30MB 是 hard code,为什么不是 10M/20M?或许这个值可以开放给使用者控制?
重构:基于文件读写的方式解析 mp4,替代以前基于流(ReadableStream)解析。
解决大体积 mp4 文件在解析阶段内存占用过大的问题。
Closes #129