winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.71k stars 567 forks source link

I have disabled gop cache,but the time of requesting for http-flv first frame is too long. #260

Closed Sectran closed 5 months ago

Sectran commented 5 months ago

I disabled gopcache,and I use tcpdump to watch when the first frame will arrive,it's cost a lot of time,plz give me some advices.

image

When I wait for a long time, the streaming server begain sends the FLV data. this is my config:

rtmp {            
    server {
        listen 1935;  
        chunk_size 4096;  
        max_message 100M;
        application video {
            play /data/video; 
        }   
          application live{
                live on; 
                gop_cache off; 
                drop_idle_publisher 300s;
                recorder rec {  
                     record all manual; 
                     record_suffix ^%Y-%m.flv;
                     record_path /data/video; 
                     record_unique off;  
                     record_append on;
                  }
        #    exec_record_done './convert_flv.sh' $dirname $path $basename 2>>/tmp/rtmp_exec.log;
        }   
    }   
}
winshining commented 5 months ago

I don't know why there was a large interval between the request and the response in your test. An HTTP response is actually driven by a rtmp publisher, if the media file pushed by a publisher has a low bit rate, it will take server some time to coalesce many chunks into a message, then the server calls the relevant handler to feed response. However, this is a trivial factor. The interval between HTTP request and response is normally at ms level, but if the directive gop_cache is off, and if the gop size is large and the request comes after the key frame in the pushing stream, player may wait a long time before a key frame arrives. Further, the directive wait_key is on by default, the server will not send any data after sending HTTP response until a key frame arrives.

Sectran commented 5 months ago

yes,in my test, publisher sends every frame in 50 secends,whethere there has an impact on the waiting time of the first frame if I disable wait_key?

Sectran commented 5 months ago

@winshining Thank you very much. Your suggestions have given me a lot of inspiration. After increasing the frequency of keyframes, the loading speed has indeed accelerated. I really appreciate it.