Get width and height from SPS and PPS (resurfacing)
mateothegreat opened this issue · 2 comments
mateothegreat commented
I'm needing the dimensions of the stream and based on #473 and #475 the SPS should be available in github.com/bluenviron/gortsplib/v4 but I can't find it..
Can ya please advise on the proper method(s) for retrieving width and height?
Thanks!! 🙏
For reference the foundH265
value comes from a simple wrapper:
func findH265(desc *description.Session) *description.Media {
var h265Format *format.H265
findH265 := desc.FindFormat(&h265Format)
return findH265
}
mateothegreat commented
Solved (had to cast it -- had a moment of weakness :)).
// Extract SPS from the first format
sps := foundH265.Formats[0].(*format.H265).SPS
var parsedSPS h265.SPS
err := parsedSPS.Unmarshal([]byte(sps))
if err != nil {
return Stream{}, fmt.Errorf("failed to parse SPS: %w", err)
}
stream.Width = parsedSPS.Width()
stream.Height = parsedSPS.Height()
log.Printf("Width: %d, Height: %d", stream.Width, stream.Height)