实时视频流的 GOP 大小

GOP size for realtime video stream

我正在开发一种丰富的远程桌面系统,其中包含使用 avcodec/x264 编码的桌面视频流。我必须手动设置流的 GOP 大小,到目前为止我使用的大小是 fps/2。 但我刚刚在维基百科上阅读了以下内容:

This structure [Group Of Picture@ suggests a problem because the fourth frame (a P-frame) is needed in order to predict the second and the third (B-frames). So we need to transmit the P-frame before the B-frames and it will delay the transmission (it will be necessary to keep the P-frame).

这意味着我造成了很多延迟,因为客户端需要接收至少一半的 GOP 才能输出 I 帧之后的第一帧。如果我想要尽可能小的延迟,GOP 大小的最佳策略是什么?一张图片的 gop ?

如果您想最大程度地减少 h264 的延迟,通常应避免使用 b 帧。这样解码器至少有机会提前发出解码帧。这可以防止解码器引起的延迟。

您可能还想通过 reducing/disabling 预测来调整编码器的延迟。 x264 有一个 "zero-latency" 设置,这应该是找到最佳设置的一个很好的起点。

"GOP" 大小(afaik 并没有真正为 h264 定义;我只是假设您指的是 I(DR) 帧间隔)不一定会影响延迟。此参数仅影响客户端必须等待多长时间才能 "sync" 在流上(time-to-first-picture)。