nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

Compiling nginx (release-1.25.1) with this module (v1.2.0) produce no HLS nor DASH streams

Open hamlatzis opened this issue 2 years ago • 1 comments

I needed to have variant streams for both HLS & DASH but since the original module from nginx doesn't support dash_variant I've tried to compile nginx from sources with this module

But no streams come out, even if I only try to use HLS, let alone both.

my configuration command line is:

./auto/configure --user=root --group=root \
                          --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx \
                          --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf \
                          --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log \
                          --pid-path=/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-client-body-temp-path=/tmp/nginx-client-body \
                          --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp --http-proxy-temp-path=/usr/local/nginx/proxy_temp \
                          --http-scgi-temp-path=/usr/local/nginx/scgi_temp --http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp \
                          --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module \
                          --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module \
                          --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_slice_module \
                          --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module \
                          --with-http_secure_link_module --with-stream  --with-stream_realip_module \
                          --add-module=/home/iosif/tmp/2bdeleted/nginx-rtmp-module/nginx-rtmp-module 

Because I had a problem in compilation with gcc 7.5.0 (-Werror=implicit-fallthrough) after configuration of nginx I've modified the created Makefile instead of

CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I/home/iosif/tmp/2bdeleted/nginx-rtmp-module/nginx-rtmp-module

to

CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wextra -Wimplicit-fallthrough -g  -I/home/iosif/tmp/2bdeleted/nginx-rtmp-module/nginx-rtmp-module

my nginx.conf file is:

worker_processes auto;
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;

events {
    worker_connections 1024;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        # Transcoding (ffmpeg needed)
        application live {
            live on;
            interleave off;
            record off;

            allow publish all;
            allow play all;

            exec_push ffmpeg -i rtmp://127.0.0.1:1935/live/$name
                  -c:v libx264 -b:v 128k -tune zerolatency -preset superfast -crf 23 -f flv rtmp://127.0.0.1:1935/hls/$name_low
                  -c:v libx264 -b:v 512k -tune zerolatency -preset superfast -crf 23 -f flv rtmp://127.0.0.1:1935/hls/$name_hi
                  -c:v libx264 -b:v 1920k -tune zerolatency -preset superfast -crf 23 -f flv rtmp://127.0.0.1:1935/hls/$name_hi_3
                  -c copy -f flv rtmp://127.0.0.1:1935/hls/$name_src

                  -c:v libx264 -b:v 1024K -bufsize 1024k -f flv rtmp://127.0.0.1:1935/dash/$name_hi
                  -c:v libx264 -b:v 832K -bufsize 832k -f flv rtmp://127.0.0.1:1935/dash/$name_med
                  -c:v libx264 -b:v 256K -bufsize 256k -f flv rtmp://127.0.0.1:1935/dash/$name_low;
        }

        application hls {
            live on;

            hls on;
            hls_allow_client_cache enabled;
            hls_path /streamServer/hls/;
            hls_playlist_length 20s;
            hls_fragment 3s;

            hls_variant _low BANDWIDTH=160000;
            hls_variant _hi  BANDWIDTH=448000
            hls_variant _hi_3  BANDWIDTH=2048000;
            hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution

            hls_variant _default BANDWIDTH=500000;
       }

       application dash {
           live on;

           dash on;
           dash_path /streamServer/dash/;
           dash_fragment 3s;
           dash_playlist_length 20s;
           dash_cleanup on;
           dash_variant _low bandwidth="256000";
           dash_variant _med bandwidth="832000";
           dash_variant _hi bandwidth="1024000" max;
       }
    }
}

http {
    default_type application/octet-stream;
    sendfile        on;
    keepalive_timeout 65;
    server_tokens off;

    gzip on;
    gzip_vary on;
    gzip_disable "msie6";
    types_hash_max_size 2048;
    client_max_body_size 1m;

    server {
        listen      80;
        server_name 127.0.0.1;

        location /hls {
            # Disable cache
            #add_header Cache-Control no-cache;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' '*';
                    add_header 'Access-Control-Max-Age' 1728000;
                    add_header 'Content-Type' 'text/plain charset=UTF-8';
                    add_header 'Content-Length' 0;
                    return 204;
            }

            # Serve a manifest file that lists the available quality levels
            if ($request_uri ~* "(\d+p)\.m3u8$") {
                set $quality $1;
                rewrite ^(.*)$ /manifest/$quality/index.m3u8 break;
            }

            #server hls fragments
            types{
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            #expires -1;

            root /streamServer/;
       }

       location /dash {
          # Disable cache
          #add_header Cache-Control no-cache;
          add_header 'Access-Control-Allow-Origin' '*';
          add_header 'Access-Control-Expose-Headers' 'Content-Length';

          # allow CORS preflight requests
          if ($request_method = 'OPTIONS') {
                  add_header 'Access-Control-Allow-Origin' '*';
                  add_header 'Access-Control-Max-Age' 1728000;
                  add_header 'Content-Type' 'text/plain charset=UTF-8';
                  add_header 'Content-Length' 0;
                  return 204;
          }

          types{
               application/dash+xml mpd;
               video/mp4 mp4;
          }

          #expires -1;

          root /streamServer/;
       }

       # This URL provides RTMP statistics in XML
       location /stat {
               rtmp_stat all;
               rtmp_stat_stylesheet stat.xsl; # Use stat.xsl stylesheet
       }
       location /stat.xsl {
               # XML stylesheet to view RTMP stats.
               root /usr/local/nginx/html;
       }
   }
}

I'm streaming from a USB camera connected on my PC using OBS and my system is Ubuntu. If I modify my nginx.conf to only have one DASH stream, keep the rest (regarding HLS) and use the original code of the module then everything works, I get one DASH stream & multiple HLS streams

Any idea?

hamlatzis avatar Jun 29 '23 10:06 hamlatzis

Hi. I'm attempting to configure dash_variant as well so my use case is same as yours. I put a stack overflow question for my issue. Could you check it out ?https://stackoverflow.com/questions/79216032/docker-wget-returning-a-404-error-for-a-github-repo

looped-monk avatar Nov 22 '24 18:11 looped-monk