Skip to content

Commit

Permalink
Update HLS realtime
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 8, 2023
1 parent bf9c97e commit a0d1a1f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 42 deletions.
2 changes: 2 additions & 0 deletions i18n/en-us/docusaurus-plugin-content-docs/current/doc/hls.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ How to reduce HLS latency? The key is to reduce the number of slices and the num
You can adjust the following three settings to reduce latency to about 6-8 seconds:

* Reduce the GOP size, e.g., set OBS's GOP to 1 second or FFmpeg's GOP to the number of FPS frames.
* Reduce the encoder's delay, for example, set OBS to `Profile` as `baseline` and choose `Tune` as `zerolatency`.
* Reduce `hls_fragment`, e.g., set it to 2 seconds or 1 second.
* Reduce `hls_window`, e.g., set it to 10 seconds or 5 seconds.
* Use low-latency players like hls.js, ijkplayer, or ffplay, and avoid high-latency players like VLC.
Expand All @@ -411,6 +412,7 @@ vhost __defaultVhost__ {
Of course, you can't reduce it too much, as it may cause insufficient buffering for the player or skipping when the player's network is poor, possibly resulting in playback failure. The lower the latency, the higher the chance of buffering. HLS latency cannot be less than 5 seconds, especially considering CDN and player compatibility.

Even after adjusting, the HLS delay won't be less than 5 seconds, and the LLHLS protocol can't reduce it further. This is because LLHLS only tries to solve the impact of the initial GOP during playback. In the above settings, we also reduced the GOP's impact through the encoder's configuration. However, network jitter and player strategy are reasons for the higher HLS delay, and they can't be solved.
If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md).

## ON HLS Notify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,9 @@ RTMP is design for low latency:

## HLS LowLatency

The latency of HLS is larger than RTMP, generally about 5s+, or 15s+ for default config.
HLS has a bigger delay than RTMP, usually more than 5 seconds. If not set up properly, it can be over 15 seconds.

Please follow the configurations:

* SRS uses `conf/hls.realtime.conf` to use small pieces, and no wait for keyframe.
* OBS configures with `Keyframe interval` to 1s.
* OBS configures with `Profile` to `baseline`, and `Tune` to `zerolatency`.
* You're not able to control the latency of player, generally about 5s+.

There is a new protocol LLHLS, which has lower startup latency, but the total latency is larger than 3s.
If you want to reduce the HLS delay, please check out [HLS LowLatency](./hls.md#hls-low-latency).

## Benchmark

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/hls.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ mount -o size=7G -t tmpfs none /ramdisk
我们可以调整下面三个配置,可以将延迟降低到6到8秒左右:

* 减少GOP大小,比如设置OBS的GOP为1秒,或者FFmpeg的GOP为FPS的帧数。
* 减少编码器的延迟,比如设置OBS为`配置(Profile)``baseline`,选择`微调(Tune)``zerolatency`
* 减少`hls_fragment`,比如设置为2秒,或者1秒。
* 减少`hls_window`,比如配置为10秒,或者5秒。
* 使用低延迟播放器,比如hls.js或者ijkplayer或ffplay,不要使用VLC等很高延迟的播放器。
Expand All @@ -416,6 +417,8 @@ vhost __defaultVhost__ {
当然,也不能减少得非常少,容易造成播放器缓冲不足,或者播放器网络不佳时跳片,可能会有播放失败。
延迟越低,卡顿概率越高,HLS的延迟并不能做到5秒之内,特别是考虑CDN和播放器的适配情况。

尽管调整后HLS的延迟会降低,但是也不会低于5秒,而且LLHLS协议也不能再降低延迟,因为LLHLS只是尝试解决了开始播放时的GOP的影响,
在上面的配置中,我们通过编码器的配置同样降低了GOP的影响,而网络抖动和播放器策略都是HLS延迟偏高的原因,而且无法解决。
如果需要5秒之内的延迟,建议使用[HTTP-FLV](./flv.md)或者[SRT](./srt.md)或者[WebRTC](./webrtc.md)等协议。

## ON HLS Notify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ RTMP的特点如下:

HLS的延迟会比RTMP要大,一般是5秒以上延迟,如果不特别配置可能在15秒以上延迟。

如果想降低HLS延迟,按如下配置:

* SRS使用`conf/hls.realtime.conf`配置,减少切片的大小,不等待关键帧。
* OBS推流配置,降低gop大小,也就是关键帧间隔(Keyframe interval)为1秒。
* OBS推流配置,选择`配置(Profile)``baseline`,选择`微调(Tune)``zerolatency`
* 播放器上延迟无法控制,一般在5秒起步。

当然HLS也推出了LLHLS,降低起播延迟,但线上环境,不会低于3秒延迟。
如果想降低HLS延迟,请参考[HLS LowLatency](./hls.md#hls-low-latency)

## Benchmark

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ RTMP的特点如下:

HLS的延迟会比RTMP要大,一般是5秒以上延迟,如果不特别配置可能在15秒以上延迟。

如果想降低HLS延迟,按如下配置:

* SRS使用`conf/hls.realtime.conf`配置,减少切片的大小,不等待关键帧。
* OBS推流配置,降低gop大小,也就是关键帧间隔(Keyframe interval)为1秒。
* OBS推流配置,选择`配置(Profile)``baseline`,选择`微调(Tune)``zerolatency`
* 播放器上延迟无法控制,一般在5秒起步。

当然HLS也推出了LLHLS,降低起播延迟,但线上环境,不会低于3秒延迟。
如果想降低HLS延迟,请参考[HLS LowLatency](./hls.md#hls-low-latency)

## Benchmark

Expand Down
8 changes: 4 additions & 4 deletions sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@
},
"collapsed": true,
"items": [
"doc/sample-rtmp-cluster",
"doc/sample-hls-cluster",
"doc/sample-http-flv-cluster",
"doc/sample-origin-cluster",
"doc/origin-cluster",
"doc/edge",
"doc/nginx-for-hls",
Expand Down Expand Up @@ -143,6 +139,10 @@
},
"collapsed": true,
"items": [
"doc/sample-rtmp-cluster",
"doc/sample-hls-cluster",
"doc/sample-http-flv-cluster",
"doc/sample-origin-cluster",
"doc/hevc",
"doc/ide",
"doc/ffmpeg",
Expand Down
2 changes: 2 additions & 0 deletions versioned_docs/version-5.0/doc/hls.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ How to reduce HLS latency? The key is to reduce the number of slices and the num
You can adjust the following three settings to reduce latency to about 6-8 seconds:

* Reduce the GOP size, e.g., set OBS's GOP to 1 second or FFmpeg's GOP to the number of FPS frames.
* Reduce the encoder's delay, for example, set OBS to `Profile` as `baseline` and choose `Tune` as `zerolatency`.
* Reduce `hls_fragment`, e.g., set it to 2 seconds or 1 second.
* Reduce `hls_window`, e.g., set it to 10 seconds or 5 seconds.
* Use low-latency players like hls.js, ijkplayer, or ffplay, and avoid high-latency players like VLC.
Expand All @@ -411,6 +412,7 @@ vhost __defaultVhost__ {
Of course, you can't reduce it too much, as it may cause insufficient buffering for the player or skipping when the player's network is poor, possibly resulting in playback failure. The lower the latency, the higher the chance of buffering. HLS latency cannot be less than 5 seconds, especially considering CDN and player compatibility.

Even after adjusting, the HLS delay won't be less than 5 seconds, and the LLHLS protocol can't reduce it further. This is because LLHLS only tries to solve the impact of the initial GOP during playback. In the above settings, we also reduced the GOP's impact through the encoder's configuration. However, network jitter and player strategy are reasons for the higher HLS delay, and they can't be solved.
If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md).

## ON HLS Notify
Expand Down
11 changes: 2 additions & 9 deletions versioned_docs/version-5.0/doc/low-latency.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,9 @@ RTMP is design for low latency:

## HLS LowLatency

The latency of HLS is larger than RTMP, generally about 5s+, or 15s+ for default config.
HLS has a bigger delay than RTMP, usually more than 5 seconds. If not set up properly, it can be over 15 seconds.

Please follow the configurations:

* SRS uses `conf/hls.realtime.conf` to use small pieces, and no wait for keyframe.
* OBS configures with `Keyframe interval` to 1s.
* OBS configures with `Profile` to `baseline`, and `Tune` to `zerolatency`.
* You're not able to control the latency of player, generally about 5s+.

There is a new protocol LLHLS, which has lower startup latency, but the total latency is larger than 3s.
If you want to reduce the HLS delay, please check out [HLS LowLatency](./hls.md#hls-low-latency).

## Benchmark

Expand Down
8 changes: 4 additions & 4 deletions versioned_sidebars/version-5.0-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@
},
"collapsed": true,
"items": [
"doc/sample-rtmp-cluster",
"doc/sample-hls-cluster",
"doc/sample-http-flv-cluster",
"doc/sample-origin-cluster",
"doc/origin-cluster",
"doc/edge",
"doc/nginx-for-hls",
Expand Down Expand Up @@ -143,6 +139,10 @@
},
"collapsed": true,
"items": [
"doc/sample-rtmp-cluster",
"doc/sample-hls-cluster",
"doc/sample-http-flv-cluster",
"doc/sample-origin-cluster",
"doc/hevc",
"doc/ide",
"doc/ffmpeg",
Expand Down

0 comments on commit a0d1a1f

Please sign in to comment.