arut / nginx-rtmp-module

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

.m3u8 and .ts files not being written occasionally #1248

Open tenacex opened 6 years ago

tenacex commented 6 years ago

I have this setup for streaming:

events {
    worker_connections  1024;
}
# RTMP configuration
rtmp {
    server {
        listen 1935; # Listen on standard RTMP port
        chunk_size 4000;
        application show {
            live on;
            allow publish all;
            allow play all;
            exec ffmpeg -i rtmp://localhost/show/$name
                              -c:a libfdk_aac -b:a 32k  -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_lo
w
                              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi
;
        }
        application hls {
            live on;
            hls on;
            hls_path /mnt/hls;
            hls_nested on;
            hls_variant _low BANDWIDTH=160000;
            hls_variant _hi  BANDWIDTH=640000;
      }
    }
}
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

http {
    sendfile off;
    tcp_nopush 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 /mnt/;
        }
    }
}

Occasionally, I'd say about 50/50, the manifest and the segments are never written to the /mnt/hls directory on my GCP box. Any obvious reasons why? Thanks

aefox commented 6 years ago

Interesting problem. I am having a similar one, but in my case I never get anything written to /tmp/hls (I'm using tmp instead of mnt). I have enough space and the permissions seem to be correct.

zunair-syed commented 5 years ago

any solution? Same thing is happening to me. @aefox @tenacex