要解决几个问题:
(1)srs服务器gop_cache如何打开和关闭?
(2)gop_cache缓存时间如何设置?
(3)服务器如何知道某个msg是gop_cache的关键帧,并且清理前面的帧。
(4)audio和video的gop_cache如何对应起来(同步)?
(5)客户端连入的时候如何把gop_cache发给客户端。
(6)gop_cache有何用?
(1)服务器gop_cache如何打开和关闭?
其实很简单,如下conf配置上加 gop_cache on/off; 即可
# the listen ports, split by space.
listen 1935;
vhost __defaultVhost__ {
# whether cache the last gop.
# if on, cache the last gop and dispatch to client,
# to enable fast startup for client, client play immediately.
# if off, send the latest media data to client,
# client need to wait for the next Iframe to decode and show the video.
# set to off if requires min delay;
# set to on if requires client fast startup.
# default: on
gop_cache on;
}
参考这里:
https://github.com/ossrs/srs/wiki/v2_CN_LowLatency#gop-cache
(2)gop_cache缓存时间如何设置?
gop_cache的时间间隔是推流的客户端决定的,跟服务器没关系。
比如:
A.基于ffmpeg实现的客户端设置可以参考如下代码,如下代码把gop_size设置为帧率大小,换算成时间就是1S。很多人设置为50,如果帧率是24fps,那么就是2s。</