I am using libX264 library for encoding purpose . After encoding data is in form of NAL Unit ()..... .This is same format( AVC) what I require but problem is one frame come in two Nal Unit ( One frame = (length,data) + (length,data) ) and i need ( One frame = (length,data) in single nal unit).While I am converting into file then play , it show first upper part of screen and then lower . My config parameter are below
param.i_width = 1680//;
param.i_height = 948;
param.i_fps_num = some no;
param.i_fps_den = 1;
param.i_keyint_max = 1 ;
param.rc.i_rc_method = //;
param.rc.f_rf_constant = //;
param.rc.f_rf_constant_max = //;
param.rc.b_mb_tree = 1;
param.rc.i_vbv_max_bitrate = ; // Convert to Kbps
param.rc.i_vbv_buffer_size = param.rc.i_vbv_max_bitrate / param.i_fps_num;
param.b_repeat_headers = 0;
param.b_annexb = 0;
Can you send your encoder code? Normally you should have the following code:
naluSize=x264_encoder_encode(h, &nal, &i_nal, pic, &pic_out);
if(naluSize_size>0)
{
memcpy(Framebuffer, nal[0].p_payload, frame_naluSize);
FrameBufferSize= frame_naluSize;
}
So you will have your encoded frame in Framebuffer and its size is in FrameBufferSize. This works like a charm in my application.
Another advice is not to touch any parameters (at least till you solve your problems) that you don't have any idea about. Just use
x264_param_default_preset(¶m, "ultrafast", "zerolatency");
This will set many parameters for you. Of course, don't forget to set the resolution :)
Need WAY more information for a complete answer, but just a guess. If the first NALU is an AUD (type 9), You can ignore it. Or do not generate them in the first place by setting b_aud = 0.
来源:https://stackoverflow.com/questions/16058109/x264-decoder-complete-frame-not-come-in-one-nal-unit