Search code examples
h.264wiresharkrtsppacketrtp

Identifying NAL Header vs Raw H264


I am working with a bunch of H264 data in Wireshark using TCP/RTSP/RTP. Right now I am trying to identify the NAL headers. How do I do this? How do I tell if my H264 data is raw or has NAL headers?

Thanks


Solution

  • The NAL headers start with the prefix code 0x000001 (sometimes 0x00000001 depending on the encoder implementation.) All the data between two prefix code consist of the data of the NAL unit. So what you would need to do if search for the start prefix code, and the following byte after it would be the NAL header.

    What you can also do is to see if Wireshark can decode the stream, using "Decode As.." -> "RTP", and Wireshark might be able to show something like

    Real-Time Transport Protocol
         10.. .... = Version: RFC 1889 Version (2)
         ..0. .... = Padding: False
         ...1 .... = Extension: True
         .... 0000 = Contributing source identifiers count: 0
         0... .... = Marker: False
         Payload type: DynamicRTP-Type-96 (96)
         Sequence number: 35525
         Timestamp: 2966614680
         Synchronization Source identifier: 0x00000001 (1)
         Defined by profile: 48862
         Extension length: 3
         Header extensions
             Header extension: 1711276032
             Header extension: 2615214809
             Header extension: 1912602625
    
        H.264
             NAL unit header or first byte of the payload
                 0... .... = F bit: No bit errors or other syntax violations
                 .01. .... = Nal_ref_idc (NRI): 1
                 ...1 1000 = Type: STAP-A (24)
             H264 bitstream
    

    for that RTP packet information.