sergey-dryabzhinsky / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
1.02k stars 217 forks source link

FFMPEG sometime can not convert RTMP to HLS stream #327

Open Hauham opened 3 years ago

Hauham commented 3 years ago

Hi team, thank you for your useful module but an issue was appeared when I using it, plz help me.

We have used nginx-rtmp-module and ffmpeg to convert rtmp to hls Everything works fine until a day .ts files are not created

The first, I guess may be nginx crash by something, I do reload nginx and everything is back to the way it was.

After that, I realized that nginx do not crash because at least nginx log work fine during the time the problem occurred

To use ngx_rtmp_module i have to add command load_module modules/ngx_rtmp_module.so; Is there any possibility that the error is caused by that module ?

What the happen in here ? What should I do to fix it ?

Here is my config Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-1029-aws x86_64) I use ffmpeg as a command line with format like : ffmpeg -i [input_rtmp] -f flv rtmp://localhost/hls/channelName

My nginx config

**load_module modules/ngx_rtmp_module.so; pid /var/run/nginx.pid; error_log /opt/data/error.log info; worker_processes 4; worker_rlimit_nofile 16384; events { worker_connections 4096; }

rtmp { server { listen 1935; chunk_size 4096; max_message 1M; buflen 500ms;

live

    wait_key on;
    wait_video on;
    sync 200ms;
   application hls {
        live on;
        hls on;
        hls_fragment 1s;
        hls_type live;
        hls_playlist_length 60s;
        hls_path /opt/data/hls;
        hls_nested on;
        hls_continuous off;
        hls_cleanup on;

        hls_fragment_naming timestamp;
        hls_variant _720 BANDWIDTH=2628000,RESOLUTION=1280x720;
        hls_variant _480 BANDWIDTH=1128000,RESOLUTION=854x480;
        hls_variant _360 BANDWIDTH=878000,RESOLUTION=640x360;
        hls_variant _240 BANDWIDTH=528000,RESOLUTION=426x240;

        #IP Publish
        allow publish all;
        allow play all;
   }

}

}

http { access_log /opt/data/access.log combined; sendfile on; include mime.types; keepalive_timeout 600; keepalive_requests 1000; ssl_ciphers HIGH:!aNULL:!MD5; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; server { listen 8080; server_name localhost;

Uncomment these lines to enable SSL.

    # Update the ssl paths with your own certificate and private key.
    #listen 443 ssl;
    #ssl_certificate     /home/ubuntu/Transcode-to-HLS/certs/example.com.crt;
    #ssl_certificate_key /home/ubuntu/Transcode-to-HLS/certs/example.com.key;

    location /hls {
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }
        root /opt/data;
        #add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
        add_header Cache-Control "max-age=1";
        add_header X-Cache-Status *;
    }
    location /live {
      alias /opt/data/hls;
      types {
          application/vnd.apple.mpegurl m3u8;
          video/mp2t ts;
      }
      #add_header Cache-Control no-cache;
      add_header Access-Control-Allow-Origin *;
      add_header Cache-Control "max-age=1";
      add_header X-Cache-Status *;
    }
    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet static/stat.xsl;
    }
    location /static {
        alias /www/static;
    }
    location = /crossdomain.xml {
        root /www/static;
        default_type text/xml;
        expires 24h;
    }
}

}**