axis,海康,大华配置rtp配置信息的比较

李国帅 取自日志2012/03/14 17:02:06


Axis实时

rtsp://192.168.17.240:554/mpeg4/1/media.amp

v=0

o=- 1332236414830792 1332236414830800 IN IP4 192.168.17.240

s=Media Presentation

e=NONE

c=IN IP4 0.0.0.0

b=AS:8000

t=0 0

a=control:*

a=range:npt=now-

a=mpeg4-iod: "data:application/mpeg4-iod;base64,AoDUAE8BAf/1AQOAbwABQFBkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9kLWF1O2Jhc2U2NCxBUjBCR3dVZkF4Y0F5U1FBWlFRTklCRUVrK0FBZWhJQUFIb1NBQVlCQkE9PQQNAQUABAAAAAAAAAAAAAYJAQAAAAAAAAAAAzoAAkA2ZGF0YTphcHBsaWNhdGlvbi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTWVFTSVVFVUZQd0E9BBICDQAAAgAAAAAAAAAABQMAAEAGCQEAAAAAAAAAAA=="

m=video 0 RTP/AVP 96

b=AS:8000

a=framerate:30.0

a=control:trackID=1

a=rtpmap:96 MP4V-ES/90000

a=fmtp:96 profile-level-id=245; config=000001B0F5000001B509000001000000012008D49588032516044814440F

a=mpeg4-esid:201

static const char* sConfig = "config=";

axis的头使用config

a=fmtp:96 profile-level-id=245; config=000001B0F5000001B509000001000000012008D49588032516044814440F

海康的头部使用MEDIAINFO。

a=Media_header:MEDIAINFO=494D4B48010100000400000110710110401F000000FA000000000000000000000000000000000000;

第一个帧是第一个关键帧,关键帧的前面数据是配置信息。

<------------------------------------------------------

0000 00 00 01 b0 f5 00 00 01 b5 09 00 00 01 00 00 00

0010 01 20 08 d4 95 88 03 25 16 04 48 14 44 0f 00 00

------------------------------------------------------>

0020 01 b3 1a 92 27 00 00 01 b2 0a 01 4f fe eb 7f cb

0030 69 ff dd 6e 69 0c 01 00 00 01 b2 0a 03 49 4f 30

0040 3a 30 3b 49 4f 31 3a 30 3b 49 4f 32 3a 30 3b 49

0050 4f 33 3a 30 3b 4d 30 3a 30 3b 4d 4c 30 3a 30 30

0060 30 3b 4d 31 3a 30 3b 4d 4c 31 3a 30 30 30 3b 56

0070 30 3a 31 3b 54 30 3a 30 3b 00 00 01 b2 0a 00 01

0080 1c 04 2f 01 00 40 8c 9b 81 b3 00 00 01 b6 12 58

0090 2c c0 a1 1c f8 39 73 1c f8 39 71 b7 d5 e6 62 0b

00a0 41 cb b8 82 d0 11 73 a7 bc d3 62 0b 40 45 cc 41

...

-----------------


大华 实时

rtsp://admin:admin@192.168.10.109:554/cam/realmonitor?channel=1&subtype=0

RTSP/1.0 200 OK

Content-Length: 307

Content-Type: application/sdp

CSeq: 7

User-Agent: DH RTSP Server

v=0

o=StreamingServer 3331435948 1116907222000 IN IP4 192.168.10.109

s=h264.mp4

c=IN IP4 0.0.0.0

t=0 0

a=control:*

m=video 0 RTP/AVP 96

a=control:trackID=0

a=rtpmap:96 H264/90000

a=fmtp:96 profile-level-id=42801E;sprop-parameter-sets=Njc0MmUwMTRkYTA1ODI1MQ==,NjhjZTMwYTQ4MA==;packetization-mode=1

rtsp://admin:admin@192.168.10.109:554/cam/realmonitor?channel=1&subtype=0

使用packetization-mode=1 非交错(non-interleaved)封包模式

base64

Njc0MmUwMTRkYTA1ODI1MQ==,NjhjZTMwYTQ4MA==

原始数据

67 42 e0 14 da 05 82 51

==,和==为分隔符

68 ce 30 a4 80

重要:从sdp中获取的sps和pps根本就不正确,必须从实际的数据中获取。

其中sps在前面,rtp包中的数据为

SPS

67:42:e0:1e:db:02:c0:49:10

PPS

68:ce:30:a4:80

图像参数不正确会造成播放的时候图像选择区域出问题。

帧类型7为sps,8为pps,所以看到67,68就应该想到这个可能是配置参数。

--------------------


海康实时

rtsp://admin:12345@192.168.17.108:554/h264/ch1/main/av_stream

RTSP/1.0 200 OK

CSeq: 9

Content-Type: application/sdp

Content-Length: 517

v=0

o=- 1109162014219182 1109162014219192 IN IP4 x.y.z.w

s=Media Presentation

e=NONE

c=IN IP4 0.0.0.0

t=0 0

a=range:npt=now-

a=control:*

m=video 0 RTP/AVP 96

a=rtpmap:96 H264/90000

a=control:trackID=1

a=fmtp:96 profile-level-id=4D0014;packetization-mode=0;sprop-parameter-sets=Z0LgHmdC4B7iWBYCSQgAADhAAA==,aM48gA==

m=audio 0 RTP/AVP 0

a=rtpmap:0 PCMU/8000

a=control:trackID=2

a=Media_header:MEDIAINFO=494D4B48010100000400000110710110401F000000FA000000000000000000000000000000000000;

a=appversion:1.0

海康的头部使用MEDIAINFO,不使用了。

a=Media_header:MEDIAINFO=494D4B48010100000400000110710110401F000000FA000000000000000000000000000000000000;

base64 分析

Z0LgHmdC4B7iWBYCSQgAADhAAA==,aM48gA==

原始数据

gB?‑gB?‑?X[1]I

h?<?

二进制为

0x67 42 e0 1e 67 42 e0 1e e2 58 16 02 49 08 00 00 -

- 38 40 00

共有19个字节

0x68 ce 3c 80

使用packetization-mode=0;单一 NALU 单元模式

获取的信息既不是媒体信息,也不是bitmap,应该是一个自定义的文件头

#if 1

char fh[40] = {0};

int len = 0;

const char *pfh = NULL;

pfh = m_pRTPRecv->GetSDPConfig();

if(pfh != NULL && strlen(pfh) > 32)

{

Hex2Binary((char*)pfh, strlen(pfh), fh, &len);

}

else

{

Hex2Binary(fileheader, ::strlen(fileheader), fh, &len);//共80字节

}

BYTE* pFormatData = pmt->AllocFormatBuffer(40);//; pmt->AllocFormatBuffer(sizeof(VIDEOINFO));

memcpy(pFormatData, fh, 40);

VIDEOINFO * pvi = (VIDEOINFO *)pFormatData;

BITMAPINFOHEADER * pvi = (BITMAPINFOHEADER *)pFormatData;

#endif

rtp中的sps帧,刚刚上线的第一帧视频一定是sps。

67:42:e0:1e:e2:58:16:02:49:08:00:00:38:40:00:0a:fc:80:20

rtp中的pps帧

68:ce:3c:80

**********************************************


新的海康设备,高清

RTSP/1.0 200 OK

CSeq: 2

Content-Type: application/sdp

Content-Base: rtsp://192.168.10.152:554/h264/ch1/main/av_stream/

Content-Length: 826

v=0

o=- 1342634236740860 1342634236740860 IN IP4 192.168.10.152

s=Media Presentation

e=NONE

b=AS:5100

t=0 0

a=control:rtsp://192.168.10.152:554/h264/ch1/main/av_stream/

m=video 0 RTP/AVP 96

b=AS:5000

a=control:rtsp://192.168.10.152:554/h264/ch1/main/av_stream/trackID=1

a=rtpmap:96 H264/90000

a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z01AKIiLUDwBE/LCAAAOEAACvyAIAAADAA==,aO44gA==

m=audio 0 RTP/AVP 0

b=AS:50

a=control:rtsp://192.168.10.152:554/h264/ch1/main/av_stream/trackID=2

a=rtpmap:0 PCMU/8000

m=application 0 RTP/AVP 107

b=AS:50

a=control:rtsp://192.168.10.152:554/h264/ch1/main/av_stream/trackID=3

a=rtpmap:107 vnd.onvif.metadata/90000

a=Media_header:MEDIAINFO=494D4B48010100000400010010710110401F000000FA000000000000000000000000000000000000;

a=appversion:1.0

base64 分析

Z01AKIiLUDwBE/LCAAAOEAACvyAIAAADAA==

00000000h: 67 4D 40 28 88 8B 50 3C 01 13 F2 C2 ; gM@(垕P<..蚵

aO44gA==

00000000h: 68 3F 80 ; h?€

Z01AKIiLUDwBE/LCAAAOEAACvyAIAAADAA==

aO44gA==

rtp中sps帧数据

0000 67 4d 40 28 88 8b 50 3c 01 13 f2 c2 00 00 0e 10 gM@(..P<........

0010 00 02 bf 20 08 00 00 03 00 00 00 00 ... ........ ..

rtp中pps帧数据

0000 68 ee 38 80 h.8.

可见新的设备已经纠正了原来的sps错误。

但是新的高清设备的长宽计算错误,计算出来的是16*16。

比较了mpeg4ip-1.5.0.1的原始例子,

void CH264Config::ParseSPS()
{
    //获取图像大小
    if (strlen(m_cbSPS) <1)return;

    CBitstream ourbs;
    ourbs.init(m_cbSPS, m_nSPS * 8);

    h264_decode_t dec;
    memset(&dec, 0, sizeof(dec));
    h264_parse_sequence_parameter_set(&dec, &ourbs);

    // get width
    nVideoWidth = 1920;//dec.pic_width;
    // get height
    nVideoHeight = 1080;//dec.pic_height;
}
void CH264Config::ParseSPS()
{
    if (strlen(m_cbSPS) <1)return;//获取图像大小

    CBitstream ourbs;
    ourbs.init(m_cbSPS, m_nSPS * 8);

    h264_decode_t dec;
    memset(&dec, 0, sizeof(dec));

    uint32_t type = 0;//新加入
    h264_check_0s(&ourbs, 1);//新加入
    dec.nal_ref_idc = ourbs.GetBits(2);//新加入
    dec.nal_unit_type = type = ourbs.GetBits(5);//新加入 需要设置单元类型
    if(type == 0x7)
    {
        h264_parse_sequence_parameter_set(&dec, &ourbs);
        nVideoWidth = dec.pic_width;//1920;//
        nVideoHeight = dec.pic_height;//1080;//
    }
}
    void h264_parse_sequence_parameter_set (h264_decode_t *dec, CBitstream *bs)
    {
...
        uint32_t PicWidthInMbs = h264_ue(bs) + 1;
        printf("   pic_width_in_mbs_minus1: %u (%u)\n", PicWidthInMbs - 1, PicWidthInMbs * 16);
        uint32_t PicHeightInMapUnits = h264_ue(bs) + 1;
        printf("   pic_height_in_map_minus1: %u\n", PicHeightInMapUnits - 1);
//已经计算长宽了,还要加入修正值。
///中间被隐掉的加上
        dec->frame_mbs_only_flag = bs->GetBits(1);
        if (!dec->frame_mbs_only_flag) {
            printf("    mb_adaptive_frame_field_flag: %u\n", bs->GetBits(1));
        }
        printf("   direct_8x8_inference_flag: %u\n", bs->GetBits(1));
        temp = bs->GetBits(1);
        if (temp) {
            printf("     frame_crop_left_offset: %u\n", h264_ue(bs));
            printf("     frame_crop_right_offset: %u\n", h264_ue(bs));
            printf("     frame_crop_top_offset: %u\n", h264_ue(bs));
            printf("     frame_crop_bottom_offset: %u\n", h264_ue(bs));
        }
        temp = bs->GetBits(1);
        if (temp)
        {
            h264_vui_parameters(dec, bs);//海康sps可能没有这个东西
        }
///中间被隐掉的加上
        dec->pic_width = PicWidthInMbs*16;
        dec->pic_height = PicHeightInMapUnits*16;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微澜-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值