efriandika / streaming-server

Docker + Nginx RTMP + S3FS (AWS S3 Integration)
https://hub.docker.com/r/efriandika/streaming-server
36 stars 17 forks source link

Broken S3FS HLS #5

Open ingageco opened 2 years ago

ingageco commented 2 years ago

I've been using this setup for a while, trying to get it ready for production. When generating adaptive HLS via and FFMPEG exec, the HLS ends up broken, streaming OK for a short while, then freezing. It's not a CPU/memory issue, as I've tried it on servers with obscenely high CPU/memory. I've attempted to use DigitalOcean Spaces (where i run the K8s stack), StackPath storage, and Amazon S3 - the issue persists in all 3. I've tried more transcoding, less transcoding, and even letting FFMPEG generate the HLS rather than pushing it into another Nginx-rtmp application. Ive tried switching out s3fs for goofys to no success - nothing solves it.

Any ideas at all what could cause this? Has anyone attempted to use this with Kubernetes at all, with adaptive bitrate HLS generation to S3 success?

ingageco commented 2 years ago

` daemon off; worker_processes 1; user root;

error_log /dev/stdout error;

events { worker_connections 1024; }

rtmp { server { listen 1935; chunk_size 4000; application embeds { live on;

        exec /usr/local/bin/ffmpeg -i rtmp://localhost:1935/embeds/$name
          -c:a libfdk_aac -b:a 128k -c:v libx264 -sc_threshold 0 -b:v 2500k -f flv -s 1280x720 -preset veryfast -profile:v main rtmp://localhost:1935/adaptive/$name_720p2628kbs
          -c:a libfdk_aac -b:a 128k -c:v libx264 -sc_threshold 0 -b:v 1000k -f flv -s 854x480 -preset veryfast -profile:v main rtmp://localhost:1935/adaptive/$name_480p1128kbs
          -c copy -f flv rtmp://localhost:1935/adaptive/$name_src -loglevel verbose 2>>/tmp/ffmpeg.log;

    }

    application adaptive {
        live on;
        hls on;

        hls_fragment_naming sequential;
        hls_fragment_slicing aligned;
        hls_fragment 6;
        hls_playlist_length 36;
        hls_path /opt/data/adaptive;
        hls_nested on;

        hls_variant _src BANDWIDTH=4128000;
        hls_variant _720p2628kbs BANDWIDTH=2628000;
        hls_variant _480p1128kbs BANDWIDTH=1128000;

    }

}

} `