How to read a h264 encoded file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amulya
    Junior Member
    Junior Member
    • Apr 2010
    • 6

    How to read a h264 encoded file.

    Hi all,

    I have downloaded a h264/avc file from elecard.com/download/clips.php. I am trying to stream this file using live555 libraries. I am struck on how to read the avc file and packetize it.

    1. How to verify the NAL unit conetnts in the h264/avc file i.e does the NAL unit have one entire frame in it or the data is distributed in multiple NAL units.
    2. To stream, I am planning to packetize one nal unit per RTP packet, (because it is the simplest way to packetize). How to extract each NAL unit from a H264 encoded file?

    This question may sound naive, but I would really appreciate any guidance on how to go about this.

    Thanks
    Amulya
  • amulya
    Junior Member
    Junior Member
    • Apr 2010
    • 6

    #2
    got it...identifying nal unts

    found this after doing a little reading here and there..

    "Basically, NAL units are separated by a simple (at least) 4-byte sequence containing a
    big-endian 1, i.e. 00 00 00 01. Finding a NAL unit boundary is therefore as simple as searching for this byte sequence. The NAL unit separators themselves are discarded, only the following NAL unit content is processed further."

    Comment

    • amulya
      Junior Member
      Junior Member
      • Apr 2010
      • 6

      #3
      I have been working on studying the h.264 bit stream format. As far as I understand, we can identify the nal units containing sequence parameter sets by looking at the nal header octet after start_code_prefix(0x000001). I think the value should be x67 for a sequence parameter set. The 3 bytes after that give us profile_level_idc. However I dont see such pattern anywhere in a sample h.264 file. Please do correct me if I am going wrong somewhere.
      Last edited by amulya; 11 Apr 2010, 03:40 PM.

      Comment

      • amulya
        Junior Member
        Junior Member
        • Apr 2010
        • 6

        #4
        Also, regarding identifying the end of access unit is by looking for a access unit delimiter nal unit which has nal header octet value of x69.

        Comment

        • amulya
          Junior Member
          Junior Member
          • Apr 2010
          • 6

          #5
          Hi all,

          I am using a tool hexedit to view the 264 stream and trying to make some sense out of it according to the 264 spec. I am looking for nal_unit_type 67 and 68 to determine the sprop_paramter_set. I have some concerns
          1. The SPS and PPS are not separated by 000001. Currenlty I am thinking the SPS ends until I encounter a 68 which indicates start of PPS. I know my understanding is wrong, but I am lost how else to read the stream.
          2. How do I know the length of SPS? There are variable length parameters in the stream.
          3. Are the sprop_paramter_set just a base 64 endoded version of these two, seprated by comma?
          Here is the portion of the stream with the parametrs
          00 17 67 4D 40 33 9A 73 80 A0 08 B4 20 00 32 E9 E0 09 89 68 11 E3 06 23 C0 01 00 04 68 EE 3C 80 00 00 00 14 62 74 72 74 00 04 4A 3E...
          How do I know where the SPS ends when there are no NAL separators? Can anybody explan what this stream means?
          Please help .
          Last edited by amulya; 14 Apr 2010, 11:35 PM.

          Comment

          • Akshay
            Junior Member
            Junior Member
            • Apr 2010
            • 1

            #6
            Some inputs which may help you
            The 4-byte sequence 0x 00 00 00 01 is the AnnexB header. It may or may not be present in the bit-stream. It is optional.
            SPS starts with 67. PPS starts with 68. And the length of SPS is variable and dependent on the toolsets enabled. The length of SPS can be known by the no of bytes between 67 and 68. in the sample bit-stream shared , SPS size is 17 bytes.
            I think using the elecard stream analyser would help you a lot

            Comment

            • kiruba
              Junior Member
              Junior Member
              • Jul 2010
              • 1

              #7
              How the separation between slice and MB??

              Hi,
              I am currently working on H.264 ip.

              00000001 byte is a separator between SPS and PPS and SLice header.. Which is demarcation line(separator) between the SLice data and MB header???


              Regards,
              Kiruba

              Comment

              • amulya
                Junior Member
                Junior Member
                • Apr 2010
                • 6

                #8
                The 264 spec says
                Nal unit synatx follows the following structure
                "byte_stream_nal_unit( NumBytesInNALunit ) { C Descriptor
                while( next_bits( 24 ) != 0x000001 &&
                next_bits( 32 ) != 0x00000001 )
                leading_zero_8bits /* equal to 0x00 */ f(8)
                if( next_bits( 24 ) != 0x000001 )
                zero_byte /* equal to 0x00 */ f(8)
                start_code_prefix_one_3bytes /* equal to 0x000001 */ f(24)
                nal_unit( NumBytesInNALunit )
                while( more_data_in_byte_stream( ) &&
                next_bits( 24 ) != 0x000001 &&
                next_bits( 32 ) != 0x00000001 )

                trailing_zero_8bits /* equal to 0x00 */ f(8)
                }"

                How do we know the NumBytesInNALunit? Also, how to identify the nal unit start in a packet oriented H264 encoded file. I read from the Annex B that in byte stream oriented files, the delimiter is used, but what about the packet oriented formats? I seem to have hit a road block here :'(

                Comment

                • ichandu
                  Junior Member
                  Junior Member
                  • Nov 2010
                  • 10

                  #9
                  Thanks
                  Friend;
                  discuss of this type of commitment......
                  According to this article.
                  nice article.......

                  Comment

                  • mbr
                    Junior Member
                    Junior Member
                    • Jun 2011
                    • 1

                    #10
                    Headers in H.264

                    Hi
                    I am working on H.264 FMO 2, ROI coding

                    I would like to know the header size for SPS and PPS in H.264,
                    and the cost of PPS in FMO type2 and FMO type6


                    Thankyou
                    Ram

                    Comment

                    Working...