Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RenderEnginePixo::video_init_params(x264_param_t* params) {
- ZeroMemory(&x264_params, sizeof(x264_params));
- if(x264_param_default_preset(params, "veryfast", "zerolatency")) {
- x264Error::throw_("x264_param_default_preset() failed");
- }
- const char* parms[] = {
- "vbv-maxrate", "500",
- "vbv-bufsize", "1666",
- "intra-refresh", NULL,
- //"fps", "30",
- "slice-max-size", "1500",
- "bitrate", "500",
- 0,0
- };
- const char** p = parms;
- while(p[0]) {
- if(x264_param_parse(params, p[0], p[1])) {
- x264Error::throw_("x264_param_parse(\"%s\", \"%s\") failed", p[0], p[1]);
- }
- p += 2;
- }
- }
- ...
- if(!x264_encoder) {
- first_frame = true;
- video_init_params(&x264_params);
- x264_params.i_width = (buffer->BufferWidth+1)&~1;
- x264_params.i_height = (buffer->BufferHeight+1)&~1;
- x264_params.i_timebase_num = 1000;
- x264_params.i_timebase_den = 15000;
- ...
- if(first_frame) {
- video_encode_starttime = systemTimeProvider.getCurrentTime();
- x264_picture.i_pts = 0;
- } else {
- //unsigned long millis = systemTimeProvider.getCurrentTime() - video_encode_starttime;
- //x264_picture.i_pts += millis;
- //x264_picture.i_pts += 10;
- x264_picture.i_pts += 1;
- }
- x264_picture.i_type = X264_TYPE_AUTO;
- x264_picture.i_qpplus1 = 0;
- x264_nal_t* nals;
- int num_nals;
- x264_picture_t pic_out;
- int n = x264_encoder_encode(x264_encoder, &nals, &num_nals, &x264_picture, &pic_out);
- //LOG("encoded: %d %d", n, num_nals);
- if(n<0) {
- x264Error::throw_("x264_encoder_encode() failed");
- }
- write_nals(nals, num_nals, x264_file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement