Open orestonce opened 3 weeks ago
还有2个关联的问题:
[SAR 1:1 DAR 16:9]
信息?func GetTsVideoInfo(tsPath string) (info TsVideoInfo) {
demuxer := mpeg2.NewTSDemuxer()
demuxer.OnFrame = func(cid mpeg2.TS_STREAM_TYPE, frame []byte, pts uint64, dts uint64) {
if cid == mpeg2.TS_STREAM_H264 {
codec.SplitFrameWithStartCode(frame, func(nalu []byte) bool {
naluType := codec.H264NaluType(nalu)
if naluType == codec.H264_NAL_SPS {
info.Width, info.Height = codec.GetH264Resolution(nalu)
start, sc := codec.FindStartCode(nalu, 0)
sodb := codec.CovertRbspToSodb(nalu[start+int(sc)+1:])
bs := codec.NewBitStream(sodb)
var s codec.SPS
s.Decode(bs)
if s.VuiParameters.NumUnitsInTick > 0 {
info.Fps = int(s.VuiParameters.TimeScale / s.VuiParameters.NumUnitsInTick / 2)
}
info.Sar = int(s.VuiParameters.SarWidth) // 这里是0
return false
}
return true
})
}
}
现在是2个都保存为宽了 https://github.com/yapingcat/gomedia/blob/17feea57090c9753003bc108ddd45d491a26b7b3/go-codec/h264.go#L489