kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
1.98k stars 439 forks source link

infinite loading #1182

Open DrunkenMonkey1 opened 4 years ago

DrunkenMonkey1 commented 4 years ago

i cant seen to make hls stream work

the error 2020/08/20 03:25:07 [error] 27050#27050: *16 ngx_child_request_wev_handler: unexpected, output buffer is null, client: 5.9.112.34, server: localhost, request: "GET /hls/1.mp4/index.m3u8 HTTP/1.1", host: "xxx.xxx.xxx"

http://domain/hls/filename is working but http://domain/hls/filename/index..m3u8 is not working it just keeps loading

nginx.conf :


`user  root; # TODO change the user 
worker_processes  auto;

error_log  /var/log/nginx/kaltura_nginx_errors.log;

#pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    multi_accept on;
    use epoll;
}

http {
    upstream kalapi {
        server localhost;
    }

    include    mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        '$status $bytes_sent $request_time "$http_referer" "$http_user_agent" "-" - '
        '"$sent_http_x_kaltura" "$http_host" $pid $sent_http_x_kaltura_session - '
        '$request_length "$sent_http_content_range" "$http_x_forwarded_for" '
        '"$http_x_forwarded_server" "$http_x_forwarded_host" "$sent_http_cache_control" '
        '$connection ';

    access_log /var/log/nginx/kaltura_nginx_access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    keepalive_timeout 60;
    keepalive_requests 1000;
    client_header_timeout 20;
    client_body_timeout 20;
    reset_timedout_connection on;
    send_timeout 20;

    gzip  on;
    gzip_types application/vnd.apple.mpegurl video/f4m application/dash+xml text/xml;
    # common vod settings
    vod_mode mapped;
    vod_upstream_location /kalapi_proxy;
    vod_upstream_extra_args "pathOnly=1";

    # shared memory zones
    vod_metadata_cache metadata_cache 512m;
    vod_mapping_cache mapping_cache 64m;
    vod_response_cache response_cache 64m;
    vod_performance_counters perf_counters;

    # common file caching / aio
    open_file_cache max=1000 inactive=5m;
    open_file_cache_valid 2m;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;
    aio on;

    server {
        listen 80;
        root /var/www;
        server_name localhost;

        #include /etc/nginx/conf.d/live.conf;
        include /etc/nginx/conf.d/kaltura.conf;

    }
    #include /etc/nginx/conf.d/ssl.conf;
}
# RTMP configuration
rtmp {
    server {
        listen 8080; # Listen on standard RTMP port
        chunk_size 4000;

        # This application is to accept incoming stream
        application kLive {
                live on; # Allows live input from above

                # ADAPTIVE BITRATE SUPPORT 
        # Once the stream is alive, transcode for adaptive streaming
                # This single ffmpeg command takes the input and transforms
                # the source into 4 different streams with different bitrate
                # and quality. The scaling done here respects the aspect
                # ratio of the input.

        # This is commented by default as it is CPU and RAM intensive 
        # If you opt to enable it, ensure you have sufficient resources.

                #exec /opt/kaltura/bin/ffmpeg -i rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/$app/$name -async 1 -vsync -1
                #        -c:v libx264 -b:v 256k -b:a 32k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/kLive/$name_low
                #        -c:v libx264 -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/kLive/$name_mid
                #        -c:v libx264 -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/kLive/$name_high
                #        -c:v libx264 -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/kLive/$name_hd720
                #        -c copy -f flv rtmp://@VOD_PACKAGER_HOST@:@RTMP_PORT@/kLive/$name_src;

                dash on;
                dash_path /var/tmp/dashme;

                hls on; # Enable HTTP Live Streaming
                # Instruct clients to adjust resolution according to bandwidth
                hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
                hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
                hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
                hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
                hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution

                hls_cleanup on;
                hls_sync 100ms;
                hls_fragment 2s;
        hls_playlist_length 300m;
                hls_path /var/tmp/hlsme/;

                # Enable recording archived files of each stream
                record all;
                # This does not need to be publicly accessible since we'll convert and publish the files later
                record_path /var/tmp/rec;
                record_suffix _%Y-%m-%d_%H-%M-%S.flv;
                record_lock on;

                # Define the two scripts that will run when recording starts and when it finishes
                exec_publish /opt/kaltura/bin/create_live_entry.php $args;
                exec_record_done /opt/kaltura/bin/upload_live_recording.php $args $path;

        }
    }
}

kaltura.conf: `

    # static files (crossdomain.xml, robots.txt etc.) + fallback to api
    location / {
        root   @STATIC_FILES_PATH@;
        try_files $uri @api_fallback;
    }

    # nginx status page
    location /nginx_status {
        stub_status on;
        access_log off;
    }

    # vod status page
    location /vod_status {
        vod_status;
        access_log off;
    }

    # internal location for vod subrequests
    #location /kalapi_proxy/ {
    #   internal;
    #   proxy_pass @PROTOCOL@://kalapi/;
    #   proxy_set_header Host $http_host;
    #}

    # serve flavor progressive (clipFrom/To are not supported with 'vod none' so they are proxied)
    location ~ ^/p/\d+/(sp/\d+/)?serveFlavor/((?!clipFrom)(?!clipTo).)*$ {
        vod none;

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

    # serve flavor HLS
    location ~ ^/hls/ {
        vod hls;
        vod_bootstrap_segment_durations 1000;
        vod_bootstrap_segment_durations 1000;
        vod_bootstrap_segment_durations 1000;
        vod_bootstrap_segment_durations 4000;

        add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
        add_header Access-Control-Allow-Headers "*";
        add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
        add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
        add_header Access-Control-Allow-Origin "*";
        expires 100d;
    }

    # serve flavor DASH
    location ~ ^/dash/ {
        vod dash;
        vod_segment_duration 4000;
        vod_bootstrap_segment_durations 3500;
        vod_align_segments_to_key_frames on;
        vod_dash_manifest_format segmenttemplate;

        add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
        add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer";
        add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
        add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
        add_header Access-Control-Allow-Origin "*";
        expires 100d;
    }

    # serve flavor HDS
    location ~ ^/hds/p/\d+/(sp/\d+/)?serveFlavor/ {
        vod hds;
        vod_segment_duration 6000;
        vod_align_segments_to_key_frames on;
        vod_segment_count_policy last_rounded;

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

    # serve flavor MSS
    location ~ ^/mss/p/\d+/(sp/\d+/)?serveFlavor/ {
        vod mss;
        vod_segment_duration 4000;
        vod_manifest_segment_durations_mode accurate;

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

    # all unidentified requests fallback to api (inc. playManifest)
    #location @api_fallback {
    #   proxy_pass @PROTOCOL@://kalapi;
    #   proxy_set_header Host $http_host;
    #}

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

            location /dashme {
                    open_file_cache off;
                    root /var/tmp;
                    add_header Cache-Control no-cache;
                    # To avoid issues with cross-domain HTTP requests (e.g. during development)
                    add_header Access-Control-Allow-Origin *;
            }
            location /hlsme {
                    open_file_cache off;
                    types {
                            application/vnd.apple.mpegurl m3u8;
                    }
                    root /var/tmp;
                    add_header Cache-Control no-cache; # Prevent caching of HLS fragments
                    add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
            }

`

other info :


` 
OS:  CentOS Linux release 8.2.2004 (Core) 
Nginx : nginx version: nginx/1.17.10
built by gcc 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)
built with OpenSSL 1.1.1c FIPS  28 May 2019
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-p                                                                      ath=/usr/lib64/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=/v                                                                      ar/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/v                                                                      ar/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --                                                                      http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var                                                                      /cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=                                                                      kaltura --group=kaltura --with-http_ssl_module --with-http_realip_module --with-                                                                      http_addition_module --with-http_sub_module --with-http_dav_module --with-http_f                                                                      lv_module --with-http_mp4_module --with-http_v2_module --with-http_gunzip_module                                                                       --with-http_gzip_static_module --with-http_random_index_module --with-http_secu                                                                      re_link_module --with-http_stub_status_module --with-http_auth_request_module --                                                                      with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-threads --wi                                                                      th-http_slice_module --with-cc-opt=-O3 --add-module=./nginx-vod-module-1.26 --ad                                                                      d-module=./nginx-secure-token-module-1.3 --add-module=./nginx-akamai-token-valid                                                                      ate-module-1.1 --add-module=./nginx-kafka-log-module-1.0 --add-module=./nginx-js                                                                      on-var-module-1.0 --add-module=./strftime-nginx-module-1.0 --add-module=./nginx-                                                                      rtmp-module-1.21.0 --add-dynamic-module=./nginx-module-vts-0.1.18 --add-dynamic-                                                                      module=./nginx-aws-auth-module-1.0.1 --add-dynamic-module=./ngx_devel_kit-0.3.1                                                                       --add-dynamic-module=./set-misc-nginx-module-0.33 --add-dynamic-module=./headers                                                                      -more-nginx-module-0.33

`

erankor commented 4 years ago

The config doesn't make sense, you have vod_mode mapped and vod_upstream_location /kalapi_proxy; but the location /kalapi_proxy is commented out. If you just want to serve local files (without mapping), you should use vod_mode local