Declare the x264_param_t struct variable:
x264_param_t params;
X264_param_default_preset (¶ms, "ultrafast", "zerolatency"); //optimize encoding delay ?
Assign values before variable parameter encoding:
params. I_CSP = (CSP = = -) ? X264_CSP_NV12:CSP;//CSP with encoded bitstream, only supports i420, color space settings#ifdef square_and_rotateparams. I_width =W; params. I_height =h;#else params. I_width =width; params. I_height =height;#endif params. Vui.i_sar_width =1; params. Vui.i_sar_height =1;//Setting the aspect ratio params. i_fps_num = Fpsnum;//Frame rate molecule params. I_fps_den = Fpsden;//Frame rate Denominator params. I_timebase_num =1; params. I_timebase_den = +;//Ms params. I_keyint_max = fpsnum/Fpsden; params. i_keyint_min = Fpsnum/fpsden;//X264_keyint_min_auto params. B_repeat_headers =0;// params. B_annexb =0; params. B_deblocking_filter =1; params. rc.f_rf_constant = -; params. rc.i_bitrate = bitrate;
Initialize the encoder:
ENC = X264_encoder_open(¶ms);
Get the entire stream of PPS and SPS?? :
int s = x264_encoder_headers(Enc, &nals, &nal_count);
-----------------------------------------------------------------
x264 Code:
Initialize picture information:
x264_picture_t Picin, Picout;
X264_picture_init (&picin);
Set the parameters of the picture information:
Picin.i_pts = ts;picin.i_type = x264_type_auto;picin.i_qpplus1 0; PICIN.IMG.I_CSP )? X264_CSP_NV12:CSP; // Special hack for Android
。。。。。。。
。。。。。。。
。。。。。
To encode a frame x264:
ret = X264_encoder_encode(Enc, &nals, &nnal, &picin, &picout);
Note: A summary is:
(1) Initialize and set x264_param_t
(2) Initialize and set x264_picture_t
(3) x264 code
=====================================================
Reference:
X264 Multithreading Analysis
Http://blog.sina.com.cn/s/blog_4ae178ba01013yix.html
x264 Coding Example
http://blog.csdn.net/xyyangkun/article/details/7255372/
x264 encoding detailed text whole process
Http://www.cnblogs.com/chuncn/archive/2011/02/25/1459805.html
Analysis of video x264 coding