Search code examples
nginxffmpeglive-streamingnginx-config

nginx live adaptive bitrate streaming:- not able to switch quality manuallly?


I am using Nginx for live adaptive bitrate streaming. My live streaming is working fine. Also, the chunks are getting created and the master playlist is also getting created as you can see in this image.

My config


        application live {
            live on; # Allows live input

            
            exec_push  /usr/bin/ffmpeg -i rtmp://localhost:1935/$app/$name
                    -force_key_frames "expr:gte(t,n_forced*3)" -c:v libx264 -vprofile baseline -vlevel 3.1 -s 640x360  -b:v 1200k  -strict -2   -c:a aac -ar 44100 -ac 2 -b:a 96k  -f flv rtmp://localhost/show/$name_hi
                -force_key_frames "expr:gte(t,n_forced*3)" -c:v libx264 -vprofile baseline -vlevel 3.1 -s 240x360  -b:v 1200k  -strict -2   -c:a aac -ar 44100 -ac 2 -b:a 96k  -f flv rtmp://localhost/show/$name_low;

                
        }



This is my master playlist enter image description here

This is my each playlist m3u8 file enter image description here

But when I point the master playlist to the videojs (hlsjs) added it is showing the quality

  1. auto
  2. undefinedp

But when I use some other test stream from online then it is showing me all available quality

using my live stream generated using nginx ffmpeg

enter image description here

using other live stream enter image description here


Solution

  • You need to add the RESOLUTION attribute to your master playlist in the EXT-X-STREAM-INF tag. This is optional in https://www.rfc-editor.org/rfc/rfc8216#section-4.3.4.2 but it's required by the quality selector UI plugin.

    See: https://github.com/chrisboustead/videojs-hls-quality-selector/issues/8

    Nginx RTMP module config example:

    hls_variant <variant_name> BANDWIDTH=<bandwidth>,RESOLUTION=<resolution>;