fix(mp4/box): 修 CreateContainerBox/WriteTo 的 typed-nil 子 box panic#3
Merged
Conversation
box.go 的 CreateContainerBox / WriteTo 用 reflect.ValueOf(child).IsNil() 判空, 对「纯 nil 接口」(zero Value)和值类型会 panic。加 isNil() helper 安全判定: 纯 nil 接口 / 可空 Kind 的 nil 值返回 true, 其余返回 false。 加 box_test.go 单测覆盖。 trailer 零重写 plan 阶段 B 的 B2;fMP4 完整实现(需先补 muxer init moov) 暂停, 本 panic 修复独立可用。
执行阶段 B 时发现: monibuca fMP4 muxer 不写 init moov box, 产物 [ftyp][moof][mdat]...[mfra] 非合法 fMP4。plan 阶段 B "moov 已在头部" 前提不成立。本次仅完成 B2(box typed-nil panic 修复), B0/B1/B3/B4 (fMP4 完整实现)暂停, 标注为后续专项。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
box.go的CreateContainerBox/WriteTo用reflect.ValueOf(child).IsNil()判空 —— 对「纯 nil 接口」(zero Value)和值类型会panic。新增isNil()helper 安全判定:纯 nil 接口、可空 Kind(指针/接口/slice 等)的 nil 值返回true,其余返回false。新增box_test.go单测覆盖。这是
2026-05-21-trailer-zero-rewriteplan 阶段 B 执行时发现的独立 bug 修复。关于阶段 B
执行阶段 B 时核实发现:monibuca 当前 fMP4 muxer 不写 init
moovbox(WriteInitSegmentfragment 分支只写ftyp,WriteMoov/MakeMoov在 fMP4 路径零调用),产物[ftyp][moof][mdat]...[mfra]非合法 fMP4。plan 阶段 B「fMP4 moov 已在头部」的前提不成立 —— fMP4 完整实现需先补全 muxer(新增 B0),工作量大于 plan 设想。阶段 A 已把 trailer 磁盘 IO 降 99%+,fMP4 边际收益较小,B0/B1/B3/B4 暂停留作后续专项(plan 已标注修订)。本 PR 仅含 B2 这个独立 panic 修复 + plan 修订说明。
Test plan
box包单测 3/3 PASS(TestIsNil/TestCreateContainerBox_SkipsNilChildren/TestWriteTo_SkipsNil)plugin/mp4/...darwin + linux 编译通过IsNil()等价)