Skip to content
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

这里有个bug,应该是一个宽、一个高 #160

Open
orestonce opened this issue Nov 3, 2024 · 1 comment
Open

这里有个bug,应该是一个宽、一个高 #160

orestonce opened this issue Nov 3, 2024 · 1 comment

Comments

@orestonce
Copy link
Contributor

现在是2个都保存为宽了

h264Vui.SarWidth = bs.Uint16(16)

@orestonce
Copy link
Contributor Author

还有2个关联的问题:

  1. 能否解析出 ffmpeg 输出的 [SAR 1:1 DAR 16:9] 信息?
  2. 目前解析出的SarWidth是0,数据应该不对
    00451.zip
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
			})
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant