简体   繁体   English

通过rtp识别h264中的idr数据包

[英]Identify idr packet in h264 over rtp

I tried to Identify idr packet in c from h264 over rtp. 我试图通过rtp从h264识别c中的idr数据包。

I follow this answer but I don't understand. 我按照这个答案,但我不明白。

Do I need to search 00 00 01 or 00 00 00 01 and than 0x65 mean start code of idr? 我是否需要搜索00 00 0100 00 00 01而不是0x65表示idr的起始代码?

Because I saw a table of all defined NALUs 因为我看到了一个包含所有已定义NALU的表

Type Name 输入名称

 0 [unspecified] 1 Coded slice 2 Data Partition A 3 Data Partition B 4 Data Partition C 5 IDR (Instantaneous Decoding Refresh) Picture 6 SEI (Supplemental Enhancement Information) 7 SPS (Sequence Parameter Set) 8 PPS (Picture Parameter Set) 9 Access Unit Delimiter 10 EoS (End of Sequence) 11 EoS (End of Stream) 12 Filter Data 13-23 [extended] 24-31 [unspecified] 

And this code that looking about another conditions (type=5 and more) 这段代码可以查看其他条件(类型= 5或更多)

public static bool 
isH264iFrame(byte[] paket)
{
    int RTPHeaderBytes = 0;

    int fragment_type = paket[RTPHeaderBytes + 0] & 0x1F;
    int nal_type = paket[RTPHeaderBytes + 1] & 0x1F;
    int start_bit = paket[RTPHeaderBytes + 1] & 0x80;

    if (((fragment_type == 28 || fragment_type == 29) && nal_type == 5 && start_bit == 128) || fragment_type == 5)
    {
        return true;
    }

    return false;
}

So how do identify idr packet? 那么如何识别idr包呢?

The code you posted does not cover all the cases. 您发布的代码并未涵盖所有案例。 You should actually start by reading the rfc on RTP payload format for H.264. 实际上,您应该首先阅读H.264的RTP有效载荷格式的rfc Depending on the RTP packetization the IDR can come in different RTP packet types: 根据RTP分组化,IDR可以采用不同的RTP数据包类型:

  • Single nal unit packet 单个单元包
  • STAP-A/STAP-B packet STAP-A / STAP-B包
  • MTAP packet MTAP包
  • FU-A/FU-B packet. FU-A / FU-B包。

The code you posted actually handles FU-A/FU-B (via the (fragment_type == 28 || fragment_type == 29) && nal_type == 5 && start_bit == 128) check) and single nal unit case (via the fragment_type == 5 check). 您发布的代码实际上处理FU-A / FU-B(通过(fragment_type == 28 || fragment_type == 29) && nal_type == 5 && start_bit == 128)检查)和单个nal单元格案例(通过fragment_type == 5检查)。 RTP actually does not use the 00 00 00 01 and 00 00 01 prefixes, those are used in Annex B format. RTP实际上不使用00 00 00 0100 00 01前缀,这些前缀用于附件B格式。 So you just need to be able to determine the type of the packet and contained NAL unit type from the RTP header. 因此,您只需要能够确定数据包的类型并包含RTP标头中的NAL单元类型。 How to do that should be clear after reading the RFC. 阅读RFC后,应该清楚如何做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM