Search code examples
nginxstreamingwinginx

Adaptive bit rate streaming not working in nginx-vod-module in NGINX server


I have installed Nginx and configured VOD for adaprive streaming using nginx-vod-module. While requesting the master.m3u8 file I'm getting same ts files served for different network bandwidth.

The master.m3u8 file has the following content:

 #EXTM3U
 #EXT-X-STREAM-INF:PROGRAMID=1,BANDWIDTH=1914317,RESOLUTION=1280x544,CODECS="avc1.64001f,mp4a.40.2"
  http://localhost/content/Input.mp4/index-v1-a1.m3u8

The Nginx configuration is:

   location /content {
        vod hls;
        vod_mode local;

        root /usr/share/nginx/html;

        gzip on;
        gzip_types application/vnd.apple.mpegurl;

        expires 100d;
        add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
    }

How can I get adaptive bitrate enabled using nginx-vod-module and what's the best way to verify it ?


Solution

    1. You encode multiple versions of your Input.mp4 with different resolutions/bitrates. The aspect ratio should be the same. Eg: Input_high.mp4, Input_low.mp4

    2. You edit the master m3u8 playlist and add each rendition with its specific bitrate and resolution:

      #EXTM3U
      #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=...,RESOLUTION=...,CODECS="..."
      /content/Input_low.mp4.m3u8
      #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=...,RESOLUTION=...,CODECS="..."
      /content/Input_high.mp4.m3u8
      
    3. When the nginx-vod-module receives a request for a filename.mp4.m3u8 it automatically segments filename.mp4 for HLS and creates the playlist for you. Eg: /content/Input_low.mp4.m3u8 for /content/Input_low.mp4