强制x264_encoder_encode仅输出一个NAL单元

时间:2019-03-29 22:28:25

标签: c++ h.264 x264

我试图弄清楚如何使x264_encoder_encode仅返回一个NAL单元。

关于如何将x264调整为每个编码周期仅产生一个NAL单元,Google并未提供任何好的结果。

x264_param_default_preset(&x264_encoder->parameters, "ultrafast", "zerolatency");

  x264_encoder->parameters.i_csp = X264_CSP_I420;
    x264_encoder->parameters.i_log_level = X264_LOG_INFO;
  x264_encoder->parameters.i_threads = 1;
  x264_encoder->parameters.b_sliced_threads = 1;
  x264_encoder->parameters.i_width = x264_encoder->Width;
  x264_encoder->parameters.i_height = x264_encoder->Height;
  x264_encoder->parameters.i_fps_num = 60;
  x264_encoder->parameters.i_fps_den = 1;
  x264_encoder->parameters.i_keyint_max = 30;
  x264_encoder->parameters.b_intra_refresh = 1;
  x264_encoder->parameters.rc.i_rc_method = X264_RC_CRF;
  x264_encoder->parameters.rc.i_vbv_buffer_size = 200;
  x264_encoder->parameters.rc.i_vbv_max_bitrate = 350;
  x264_encoder->parameters.rc.f_rf_constant = 20;
  x264_encoder->parameters.rc.f_rf_constant_max = 30;
  x264_encoder->parameters.i_sps_id = 7;
    x264_encoder->parameters.i_slice_max_size = 1200;
  x264_encoder->parameters.b_repeat_headers = 1;
  x264_encoder->parameters.b_annexb = 1;
    x264_encoder->parameters.b_opencl = 1;

  x264_param_apply_profile(&x264_encoder->parameters, "baseline");

x264_encoder->frameSize = x264_encoder_encode(x264_encoder->encoder,
  &x264_encoder->nals, &x264_encoder->i_nals, &x264_encoder->picture_in,
  &x264_encoder->picture_out);

我希望x264_encoder->i_nals每次都等于1。相反,它偶尔最多变化4或5

0 个答案:

没有答案