I am trying to create a server that streams HLS to client. I created .m3u8 file and for receive from client use Apache web server. Some times, changing the source of video takes more than usual time... I think that it refers to web server that responds to client with delay. Can anyone help me which web server is best to put m3u8 file in that and get client stream from that?

My m3u8 file is :

  • It could also depend on the segment size. Depending on the implementation, the quality switch may only happen once the current segment is done playing. If your segments are really long, there can be a long delay depending on where in the segment you switched quality. Mar 2, 2016 at 9:39
  • @MattiVirkkunen i add my m3u8 file to question, duration is 11 second and apple recommend to set it around 10 sec, so i think it not refer to size, whats your opinion?
    – ALiS
    Mar 2, 2016 at 9:43
  • I don't understand what you mean by "i think it not refer to size". Does switching quality sometimes take longer than 10 seconds for you? Mar 2, 2016 at 9:45
  • no it take maximum 5 or 6 seccond
    – ALiS
    Mar 2, 2016 at 9:46
  • as you say if i set TARGETDURATION to lower value such as 2 second changing time is faster?
    – ALiS
    Mar 2, 2016 at 9:47

2 Answers 2


The problem you're facing is the high latency of HLS, which causes a longer delay for viewers to see new content when switching live content, such as changing cameras or restarting the stream. In simple terms: How to reduce the end-to-end latency of HLS.

Generally, HLS latency is around 30 seconds. This is because TS segments are typically set to 10 seconds per TS file, and the window (number of TS files) is set to 6, resulting in a total duration of 60 seconds for TS files in the M3U8 playlist. If the player starts requesting segments from the middle position, i.e., from the third-to-last segment, the latency will naturally be around 30 seconds.

You can reduce these two parameters, for example, by changing the TS file duration to 2 seconds, which will result in a latency of 6 to 8 seconds. Due to the HLS segment and window mechanism, it is difficult to optimize the latency to less than 8 seconds, as players may encounter network delays, segment loading failures, and retries, with different behaviors for different players. For more details, please refer to SRS HLS Latency. The config for SRS media server:

vhost __defaultVhost__ {
    hls {
        enabled  on;
        hls_fragment 2;
        hls_window 10;

If you want to reduce the latency to within 3 seconds, you need to change the streaming protocol to HTTP-FLV. For more information, please refer to SRS FLV. Since iOS Safari does not yet support MSE, you still need to use HLS or WebRTC protocol. The config for SRS media server:

vhost __defaultVhost__ {
    http_remux {
        enabled on;

If you want to reduce the latency to within 1 second or achieve low latency on iOS Safari, you can use the WebRTC protocol. For more information, please refer to SRS WebRTC. The config for SRS media server:

rtc_server {
    enabled on;
vhost __defaultVhost__ {
    rtc {
        enabled on;
        rtmp_to_rtc on;

The root cause of this problem is not the Nginx distribution server, but the HLS segmentation mechanism and streaming protocol. It is recommended to switch to the SRS media server, which supports all these protocols and has the following workflow:

OBS/FFmpeg --RTMP--> SRS Media Server ---+--HTTP-FLV----> Browser
                                         +--HLS/WebRTC--> iOS Safari

Note: WebRTC is generally used in the online conferencing field and is gradually being applied in low-latency broadcasting. The protocol used to push streams with WebRTC is called WHIP, similar to RTMP, and the protocol used to play streams with WebRTC is called WHEP, similar to HLS.


I'm working in a Live Streaming company in Singapore, and we use Nginx as the web server for HLS. Since Nginx is way better at processing static files. You never need to worry about the performance, nginx can utilize the 10G network card easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.