如何获取h264视频流的分辨率

How to get resolution of h264 video stream

我正在做一个 SIP 客户端,但遇到了一些问题。 我通过 SIP 服务器邀请用户,并从中获取 SDP 参数。 但是,用户客户端 (MicroSip) 没有在 SDP 中发送 sdprop-params。 此外,它也没有在 RTP 流中发送 SPS/PPS 个切片。

这种方式如何获取图片参数?

Wireshark 转储

        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): - 1516869540 1516869540 IN IP4 172.16.50.175
            Session Name (s): mss
            Connection Information (c): IN IP4 172.16.50.175
            Time Description, active time (t): 0 0
            Media Description, name and address (m): audio 4000 RTP/AVP 97 100
            Connection Information (c): IN IP4 172.16.50.175
            Media Attribute (a): rtcp:4001 IN IP4 172.16.50.175
                Media Attribute Fieldname: rtcp
                Media Attribute Value: 4001 IN IP4 172.16.50.175
            Media Attribute (a): sendrecv
            Media Attribute (a): rtpmap:97 opus/48000/2
                Media Attribute Fieldname: rtpmap
                Media Format: 97
                MIME Type: opus
                Sample Rate: 48000
            Media Attribute (a): fmtp:97 maxplaybackrate=24000
                Media Attribute Fieldname: fmtp
                Media Format: 97 [opus]
                Media format specific parameters: maxplaybackrate=24000
            Media Attribute (a): rtpmap:100 telephone-event/8000
                Media Attribute Fieldname: rtpmap
                Media Format: 100
                MIME Type: telephone-event
                Sample Rate: 8000
            Media Attribute (a): fmtp:100 0-16
                Media Attribute Fieldname: fmtp
                Media Format: 100 [telephone-event]
                Media format specific parameters: 0-16
            Media Description, name and address (m): video 4002 RTP/AVP 97
            Connection Information (c): IN IP4 172.16.50.175
            Media Attribute (a): rtcp:4003 IN IP4 172.16.50.175
                Media Attribute Fieldname: rtcp
                Media Attribute Value: 4003 IN IP4 172.16.50.175
            Media Attribute (a): sendrecv
            Media Attribute (a): rtpmap:97 H264/90000
                Media Attribute Fieldname: rtpmap
                Media Format: 97
                MIME Type: H264
                Sample Rate: 90000
            Media Attribute (a): fmtp:97 profile-level-id=42801e; packetization-mode=0
                Media Attribute Fieldname: fmtp
                Media Format: 97 [H264]
                Media format specific parameters: profile-level-id=42801e
                    Profile: 42801e
                Media format specific parameters: packetization-mode=0
                    [Packetization mode: Single NAL mode (0)]

Сlient每1秒发送一次SPS/PPS slicec,你必须等待

SPS/PPS 可能只会在启动时发送,而不会再次发送,具体取决于视频发送器。例如Polycom VVX 视频电话

从 SDP 中,您只能找到基于 Profile 值的最大比特率,这将限制可以接收的内容。请注意我说的是

42801e 的配置文件值为:

因此这将定义最大比特率和基于该比特率的可能分辨率作为级别支持以及配置文件 (CBP) 支持的 H264 功能。

要强制向您发送 SPS/PPS,可以按照 RFC5168 向视频发送器发送媒体控制命令。当您检测到丢失的数据包或用户请求时,您应该发送其中一个(即用户看到一张损坏的图片并表示他们想要刷新)。如果你愿意,可以定期发送。