2

I would like to produce a zerolatency live video stream and play it in VLC player with as little latency as possible.

This are the settings I currently use:

x264_param_default_preset( &m_Params, "veryfast", "zerolatency" );

m_Params.i_threads              =   2;
m_Params.b_sliced_threads       =   true;
m_Params.i_width                =   m_SourceWidth;
m_Params.i_height               =   m_SourceHeight;

m_Params.b_intra_refresh        =   1;

m_Params.b_vfr_input            =   true;
m_Params.i_timebase_num         =   1;
m_Params.i_timebase_den         =   1000;

m_Params.i_fps_num              =   1;
m_Params.i_fps_den              =   60;

m_Params.rc.i_vbv_max_bitrate   =   512;
m_Params.rc.i_vbv_buffer_size   =   256;
m_Params.rc.f_vbv_buffer_init   =   1.1f;

m_Params.rc.i_rc_method         =   X264_RC_CRF;
m_Params.rc.f_rf_constant       =   24;
m_Params.rc.f_rf_constant_max   =   35;

m_Params.b_annexb               =   0;
m_Params.b_repeat_headers       =   0;
m_Params.b_aud                  =   0;

x264_param_apply_profile( &m_Params, "high" );

Using those settings, I have the following issues:

  • VLC shows lots of missing frames (see screenshot, "verloren"). I am not sure if this is an issue.
  • If I set a value <200ms for the network stream delay in VLC, VLC renders a few frames and than stops to decode/render frames.
  • If I set a value >= 200ms for the network stream delay in VLC, everything looks good so far but the latency is, obviously, 200ms, which is too high.

Question: Which settings (x264lib and VLC) should I use in order to encode and stream with as little latency as possible?

enter image description here

4

2 回答 2

4

在您的 x264 设置上:许多是多余的,即已经包含在“零延迟”中。但是,据我所知,您的编码延迟仍然为零帧,即您放入一帧,然后立即(无论如何,只要您的 CPU 完成编码)就取出一帧。它从不等待较新的帧以提供编码的较旧帧(例如,它与前瞻的方式)。

关于为什么 vlc 暂停,除非你给它一个很大的网络延迟:问题是你在编码时的速率控制和 vbv 设置的组合并不理想。您想要为低延迟编码做的是使用 CBR,并将 VBV 缓冲区设置为一帧的大小。如果您查看 x264 源代码,这将启用特殊的 VBV 计算。

您也可以尝试不设置任何与时间相关的内容(无 fps,无 vbv),并使用零延迟的 CRF。结果将取决于视频打包在哪个容器中以进行流式传输。

阅读本文了解更多信息:http: //x264dev.multimedia.cx/archives/249

于 2013-11-27T14:03:47.697 回答
1

如果您想获得尽可能快的编码,请在之后删除所有内容

x264_param_default_preset( &m_Params, "veryfast", "zerolatency" );

并从非常快变为超快。剩下的就是因为网络延迟+解码。

于 2014-01-10T15:01:10.577 回答