WWBN / AVideo

Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
https://avideo.tube/AVideo_OpenSource
Other
1.91k stars 972 forks source link

Loading HLS video before playing #4159

Closed palich91 closed 3 years ago

palich91 commented 3 years ago

I suggest making a download for HLS before playing the video

For instance: When HLS video is of good quality and long, it happens that the video starts to freeze, and this scares off visitors. I suggest you implement so that the video is first loaded and then played You need to make an option so that the administrator can specify the size of the HLS preload (for example: 15 MBytes)

jengajenga commented 3 years ago

this is already done in the nginx.conf file. you can change the parametres like fragment and playlist size.

also, the playlist is loaded by default. all m3u8 playlists have to load a minimum of 3 .ts files before it begins to play. so the smaller the better, but this can also cause issues if your internet has bad latency.

2-6 seconds is sufficient for fragment size.

palich91 commented 3 years ago

Help a little, here is my nginx.conf tell me how best to do so that people who have bad Internet use videos without freezing

`
            server {
                    listen 1935;
                    allow play all;
                    #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
                    application live {
                            allow play all;
                            live on;
                            hls on;
                            hls_nested on;
                            hls_path /HLS/live;
                            hls_fragment 2s;
                            on_publish http://localhost/AVideo/plugin/Live/on_publish.php;
                            on_play http://localhost/AVideo/plugin/Live/on_play.php;
                            on_record_done http://localhost/AVideo/plugin/Live/on_record_done.php;
                        #exec ffmpeg -i rtmp://localhost/live/$name 
                        #    -c:a aac -strict -2 -b:a 96k -c:v libx264 -vf scale=-2:240 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 400k -maxrate 700k -bufsize 1200k -b:a 96k -r 20 -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_low  
                        #    -c:a aac -strict -2 -b:a 128k -c:v libx264 -vf scale=-2:480 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1200k -maxrate 2100k -bufsize 2400k -b:a 128k -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_mid  
                        #    -c:a aac -strict -2 -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2400k -maxrate 4200k -bufsize 100000k -b:a 128k -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_hi;

                        #recorder video{
                        #    record all;
                        #    record_path /var/www/tmp;
                        #    record_notify on;
                        #    record_max_size 2048M; 
                        #    record_suffix -%d-%b-%y-%T.flv;
                        #}
                }

                #application adaptive {
                #    live on; 
                #    hls on; 

                #    hls_path /HLS/live;
                #    hls_nested on;
                #    hls_playlist_length 10m;
                #    allow play all;
                #    allow publish 127.0.0.1;
                #    deny publish all;

                #    hls_variant _low BANDWIDTH=400000;
                #    hls_variant _mid BANDWIDTH=2100000;
                #    hls_variant _hi  BANDWIDTH=4200000;
                #}
        }
}
http {
        include       mime.types;
        default_type  application/octet-stream;
        server {
                #listen 8443 ssl;
                #listen [::]:8443 ssl;
                #include /usr/local/nginx/snippets/self-signed.conf;
                #include /usr/local/nginx/snippets/ssl-params.conf;
                listen 8080;
                server_name localhost clikplay.ru www.clikplay.ru;
                #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8"      
                location /live {
                        # Disable cache
                        add_header 'Cache-Control' 'no-cache';

`

jengajenga commented 3 years ago

My setup takes into account server distance aka latency. fragment is 4s and 6s (2 different servers) playlist length is 45s and 60s

i had even gone as low as 500ms but i realised smaller doesn't always mean better/faster.

also there's the hls plugin which may help you since it works with adaptive bitrates.

DanielnetoDotCom commented 3 years ago

Adaptive bitrates will increase latency.

small fragments request more DIsk IO, and usually, Disk IO is the bottleneck for smaller latency.

If you are using Adaptive, the CPU may also be a bottleneck.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

akhilleusuggo commented 3 years ago

I've been searching for this , we need LHLS to be able to achieve it ( Low Latency HLS )

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.