The input data is ready, and the encoded data is in an array of x264_nal_t. The parameter I set here is baseline profile, so there is no B-frame after encoding, after the encoding of the data after the analysis found that the first time there will be 4 nal, SPS, PPS, SEI, I-frame, respectively, is 00 00 00 01 67, 00 00 00 01 68 , 00 00 01 06, 00 00 01 The beginning of 65 data segments, it is noted that the SEI and I frame at the beginning of the X264 is four 00 00 of the starting head, should be and the source of such a relationship, but there is no big deal, is the back in the beginning of the deletion of these starting head will have two kinds of judgement. Then encode the second frame image, get a nal, is P-frame 00 00 01 41.
Here are some of the parameters I encountered and confusion, at first I found in the analysis of the data, the first time is 5 nal, that is, SPS, PPS, SEI, I-frame, I-frame, the second time the encoding is 2 nal, that is, p-frame, p-frame, this is how it happened, the original is a number of threads running param.b_sliced_threads= false; you will find it normal.
And I have to control a few p, that is, the number of a GOP, then you need to set the value of M_param.i_keyint_max. The other is in m_param.b_repeat_headers = 1; Repeating the Sps/pps is placed in front of the keyframe, so that the setting facilitates decoding of the SPS and PPS in each I-frame.
H264 data after encoding with X264