mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
新增hls快速注册相关配置,提高hls打开速度 (#3024)
新增配置项:hls.fastRegister,默认关闭。 开启后首个切片文件只保存一个gop,可提高hls注册速度,加快播放器打开速度。 但是第一个切片播放完毕,第二个切片需要更长时间生成,可能导致播放器等待加载。
This commit is contained in:
parent
e81ff307c7
commit
1cbfcd96e2
@ -140,6 +140,8 @@ deleteDelaySec=10
|
|||||||
#0为不保留,不起作用
|
#0为不保留,不起作用
|
||||||
#1为保留,则不删除hls文件,如果开启此功能,注意磁盘大小,或者定期手动清理hls文件
|
#1为保留,则不删除hls文件,如果开启此功能,注意磁盘大小,或者定期手动清理hls文件
|
||||||
segKeep=0
|
segKeep=0
|
||||||
|
#如果设置为1,则第一个切片长度强制设置为1个GOP。当GOP小于segDur,可以提高首屏速度
|
||||||
|
fastRegister=0
|
||||||
|
|
||||||
[hook]
|
[hook]
|
||||||
#是否启用hook事件,启用后,推拉流都将进行鉴权
|
#是否启用hook事件,启用后,推拉流都将进行鉴权
|
||||||
|
@ -305,6 +305,7 @@ const string kSegmentRetain = HLS_FIELD "segRetain";
|
|||||||
const string kFileBufSize = HLS_FIELD "fileBufSize";
|
const string kFileBufSize = HLS_FIELD "fileBufSize";
|
||||||
const string kBroadcastRecordTs = HLS_FIELD "broadcastRecordTs";
|
const string kBroadcastRecordTs = HLS_FIELD "broadcastRecordTs";
|
||||||
const string kDeleteDelaySec = HLS_FIELD "deleteDelaySec";
|
const string kDeleteDelaySec = HLS_FIELD "deleteDelaySec";
|
||||||
|
const string kFastRegister = HLS_FIELD "fastRegister";
|
||||||
|
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
mINI::Instance()[kSegmentDuration] = 2;
|
mINI::Instance()[kSegmentDuration] = 2;
|
||||||
@ -314,6 +315,7 @@ static onceToken token([]() {
|
|||||||
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
||||||
mINI::Instance()[kBroadcastRecordTs] = false;
|
mINI::Instance()[kBroadcastRecordTs] = false;
|
||||||
mINI::Instance()[kDeleteDelaySec] = 10;
|
mINI::Instance()[kDeleteDelaySec] = 10;
|
||||||
|
mINI::Instance()[kFastRegister] = false;
|
||||||
});
|
});
|
||||||
} // namespace Hls
|
} // namespace Hls
|
||||||
|
|
||||||
|
@ -350,6 +350,8 @@ extern const std::string kFileBufSize;
|
|||||||
extern const std::string kBroadcastRecordTs;
|
extern const std::string kBroadcastRecordTs;
|
||||||
// hls直播文件删除延时,单位秒
|
// hls直播文件删除延时,单位秒
|
||||||
extern const std::string kDeleteDelaySec;
|
extern const std::string kDeleteDelaySec;
|
||||||
|
// 如果设置为1,则第一个切片长度强制设置为1个GOP
|
||||||
|
extern const std::string kFastRegister;
|
||||||
} // namespace Hls
|
} // namespace Hls
|
||||||
|
|
||||||
////////////Rtp代理相关配置///////////
|
////////////Rtp代理相关配置///////////
|
||||||
|
@ -111,11 +111,11 @@ void HlsMaker::delOldSegment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HlsMaker::addNewSegment(uint64_t stamp) {
|
void HlsMaker::addNewSegment(uint64_t stamp) {
|
||||||
if (!_last_file_name.empty() && stamp - _last_seg_timestamp < _seg_duration * 1000) {
|
GET_CONFIG(bool, fastRegister, Hls::kFastRegister);
|
||||||
//存在上个切片,并且未到分片时间
|
if (_file_index > fastRegister && stamp - _last_seg_timestamp < _seg_duration * 1000) {
|
||||||
|
//确保序号为0的切片立即open,如果开启快速注册功能,序号为1的切片也应该遇到关键帧立即生成;否则需要等切片时长够长
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//关闭并保存上一个切片,如果_seg_number==0,那么是点播。
|
//关闭并保存上一个切片,如果_seg_number==0,那么是点播。
|
||||||
flushLastSegment(false);
|
flushLastSegment(false);
|
||||||
//新增切片
|
//新增切片
|
||||||
|
Loading…
Reference in New Issue
Block a user