Search code examples
nginxvideo-streamingrtmp

Nignx rtmp module m3u8 file not generated


I am trying to create a local streaming server with nginx rtmp module. The server itself seems to be working fine as I can stream to server with OBS. Server is storing .ts video files under "/usr/local/nginx/sbin/hls" directory but it does not creates a m3u8 file associated with them.

Configuration file is as follows;

#user  nobody;
worker_processes  auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

rtmp {

    server {

        listen 1935;  #listen port

        chunk_size 4096;


        application live {  #rtmp push stream request path 
            live on;
            hls on;
            hls_path /usr/local/nginx/sbin/hls/;
            hls_fragment 3s;
            hls_playlist_length 18s;
        deny play all;
        }
    }
}


http {
    sendfile off;
    tcp_nopush on;
    # aio on;
    directio 512;
    default_type application/octet-stream;

    server {
        listen 8080;

        location / {
            # Disable cache
            add_header 'Cache-Control' 'no-cache';

            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            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;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            root /usr/local/nginx/sbin/;
        }
    }
}

Solution

  • Solution is fixed by setting a stream key. Generated video files were named -n.ts (n being the video number). After setting a stream key, files names became "streamkey-n.ts"