Friday 21 August 2020

set Value to HEVCDecoderConfigurationRecord

I want to use Rtmp to push H265, so need to flv support H265and HEVCDecoderConfigurationRecord ,but i donot know how to set the value to :Where can I find HEVC \ H.265 specs

   aligned(8) class HEVCDecoderConfigurationRecord
   {
unsigned int(8) configurationVersion = 1;
unsigned int(2) general_profile_space;
unsigned int(1) general_tier_flag;
unsigned int(5) general_profile_idc;
unsigned int(32) general_profile_compatibility_flags;
unsigned int(48) general_constraint_indicator_flags;
unsigned int(8) general_level_idc;
bit(4) reserved = ‘1111’b;
unsigned int(12) min_spatial_segmentation_idc;
bit(6) reserved = ‘111111’b;
unsigned int(2) parallelismType;
bit(6) reserved = ‘111111’b;
unsigned int(2) chroma_format_idc;
bit(5) reserved = ‘11111’b;
unsigned int(3) bit_depth_luma_minus8;
bit(5) reserved = ‘11111’b;
unsigned int(3) bit_depth_chroma_minus8;
bit(16) avgFrameRate;
bit(2) constantFrameRate;
bit(3) numTemporalLayers;
bit(1) temporalIdNested;
unsigned int(2) lengthSizeMinusOne;
unsigned int(8) numOfArrays;
for (j=0; j < numOfArrays; j++)
{
    bit(1) array_completeness;
    unsigned int(1) reserved = 0;
    unsigned int(6) NAL_unit_type;
    unsigned int(16) numNalus;
    for (i=0; i< numNalus; i++)
    {
        unsigned int(16) nalUnitLength;
        bit(8*nalUnitLength) nalUnit;
    }
}

}

public static void writeFirstVideoTag(ByteBuffer buffer,byte[] vps ,byte[] sps, byte[] pps) {
    //写入Flv Video Header
    //wangpeng h265
        writeVideoHeader(buffer, FlvVideoFrameType.KeyFrame, FlvVideoCodecID.HEVC, FlvVideoAVCPacketType.SequenceHeader);
        //https://github.com/donwg/msnet/blob/8704f78ecb41960d9d29038cc1af4fd3e0f20a24/utils/UtilRtmp.h
        buffer.put((byte)0x1C); //0x1c


        // general_profile_idc 8bit
        buffer.put(sps[1]);
        // general_profile_compatibility_flags 32 bit
        buffer.put(sps[2]);
        buffer.put(sps[3]);
        buffer.put(sps[4]);
        buffer.put(sps[5]);


        // 48 bit NUll nothing deal in rtmp
        buffer.put(sps[6]);
        buffer.put(sps[7]);
        buffer.put(sps[8]);
        buffer.put(sps[9]);
        buffer.put(sps[10]);
        buffer.put(sps[11]);


        // general_level_idc
        buffer.put(sps[12]);


        // 48 bit NUll nothing deal in rtmp  24
        for(int i=0;i<4;i++){// 6
            buffer.put((byte)0x00);
        }


        // bit(16) avgFrameRate;
        buffer.put((byte)0x00);
        buffer.put((byte)0x00);


        /* bit(2) constantFrameRate; */
        /* bit(3) numTemporalLayers; */
        /* bit(1) temporalIdNested; */
        buffer.put((byte)0x00);


        /* unsigned int(8) numOfArrays; 03 */
        buffer.put((byte)0x03);


        // vps 32
        buffer.put((byte)0x20);
        buffer.put((byte)0x00);
        buffer.put((byte)0x01);
        //todu vps
        buffer.putShort((short)vps.length); //33
        buffer.put(vps);


        // sps 33
        buffer.put((byte)0x21);
        buffer.put((byte)0x00);
        buffer.put((byte)0x01);
        buffer.putShort((short)sps.length);
        buffer.put(sps);


        // pps
        buffer.put((byte)0x22);  // pps 34
        buffer.put((byte)0x00);
        buffer.put((byte)0x01);
        buffer.putShort((short)pps.length);
        buffer.put(pps);


}

if the buffer is set correct can you give me some advice?



from set Value to HEVCDecoderConfigurationRecord

No comments:

Post a Comment