Analysis of video x264 coding

Source: Internet
Author: User

Declare the x264_param_t struct variable:

x264_param_t params;

X264_param_default_preset (&params, "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(&params);

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.