annexb pattern: startcode 00000001 AVCC pattern: nothing startcode (mp4 flv mkv) const AVBitStreamFilter *bsfilter = av_bsf_get_by_name( " h264_mp4toannexb " ) Īv_bsf_alloc(bsfilter, &bsf_ctx) // AVBSFContext Īvcodec_parameters_copy(bsf_ctx->par_in, ifmt_ctx->streams-> codecpar) What needs to be done B Change the length to 00000001 or 000001 FLV When packaging, multiple NALU Put it in one VIDEO TAG in,The structure is 4 B NALU length+NALU1+4B NALU length+NALU2+., FLV/MP4/MKV In other structures, h264 need h264_mp4toannexb handle. Next nalu position: 0x7dc0 + 0x025d + 4 = 0x8021, as shown in Figure 2Ĥ.AVPacket is converted to} AnnexB and H264 is used_ mp4toannexbĬode: // 1 Get the corresponding bitstream filter Indicates that there is more than one nalu. The previous size represents the size of nalu (excluding itself)Īs shown in Figure 1, the first four bytes indicate that the first nalu size is 0x52d = 1325, and the total pkt size is 66736. The data format in AVPacket is: size (4 bytes) + nalu + size (4 bytes) + nalu. At the same time, SPS and PPS data also need to be saved in extradata or 'sequence header'. Therefore, when parsing AVCC format, you need to save the value of the specified prefix bytes in a header object, which is usually called extradata or sequence header. This format adds a prefix of large end format (1, 2 and 4 bytes, representing the length of NALU) before each NALU #Ffmpeg h264 example code#□□□ Therefore, the decoder can decode from the random point of the video stream, which is a real-time stream formatĪVCC format does not use the start code as the boundary of NALU. In AnnexB format, each NALU contains the start code, and SPS and PPS are usually repeated periodically before the key frame For example, it is easy to divide the stream data with 31 consecutive bit0 followed by bit1. The 4-byte start code is very useful in continuous data transmission, because it is easy to align and divide the stream data with bytes. ② between 4 bytes 0x00000001 frames, or before SPS, etc ① interval between 3 bytes 0x000001 single frame multiple slice s (i.e. Start prefix (00000001 or 000001) + the default output format of most encoders of NALU data H264 has two encapsulation modes: byte stream AnnexB format AVCC format.ġ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |