-
Hey there, I was wondering how to calculate the width and height from the PPS and SPS (h264). Couldn't find an example, I would like to be able to know without decoding an image. Kind regards |
Beta Was this translation helpful? Give feedback.
Answered by
aler9
Dec 1, 2023
Replies: 1 comment 1 reply
-
Hello, i remember i posted an example some time ago but i can't find it anymore, anyway, here's what you're looking for. package main
import (
"fmt"
"github.com/bluenviron/gortsplib/v4"
"github.com/bluenviron/gortsplib/v4/pkg/base"
"github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediacommon/pkg/codecs/h264"
)
func main() {
c := gortsplib.Client{}
// parse URL
u, err := base.ParseURL("rtsp://localhost:8554/mystream")
if err != nil {
panic(err)
}
// connect to the server
err = c.Start(u.Scheme, u.Host)
if err != nil {
panic(err)
}
defer c.Close()
// find available medias
desc, _, err := c.Describe(u)
if err != nil {
panic(err)
}
// find the H264 media and format
var forma *format.H264
medi := desc.FindFormat(&forma)
if medi == nil {
panic("media not found")
}
var sps h264.SPS
err = sps.Unmarshal(forma.SPS)
if err != nil {
panic(err)
}
fmt.Println("Width:", sps.Width())
fmt.Println("Height:", sps.Height())
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
cedricve
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, i remember i posted an example some time ago but i can't find it anymore, anyway, here's what you're looking for.