WerkzeugSchuppen/VideostreamingNginxDefaultConfig

Aus Chaos Computer Club Bremen e.V. (CCCHB)
Wechseln zu: Navigation, Suche
#user  nobody;
worker_processes  1;

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

pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

# http für die Statspage, rtmp weiter unten
http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       [::1]:8080;
        listen       127.0.0.1:8080;
#        server_name  localhost;

        # sample handlers
        #location /on_play {
        #    if ($arg_pageUrl ~* localhost) {
        #        return 201;
        #    }
        #    return 202;
        #}
        #location /on_publish {
        #    return 201;
        #}

        #location /vod {
        #    alias /var/myvideos;
        #}

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/src/nginx-rtmp-module;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen [::]:1935;
#        listen 1935;
        ping 30s;
        notify_method get;

        chunk_size 128;

        buflen 1s;

        # stream von diesem Server abrufbar, plus push zu Youtube und Twitch simultan, keine lokale Aufzeichnung
        application live {
            live on;
            record off;

            push rtmp://live.twitch.tv/app/live_#####_###########; #  ###=ID_STREAM KEY
            push rtmp://a.rtmp.youtube.com/live2/####-####-####-####; #  ###=STREAM KEY
        }

        # stream von diesem Server unter rtmp://$SERVER/local/$SENT_STREAM_KEY abrufbar
        application local {
            live on;
            record off;
        }

        # template für was sonst noch so geht:
        application template {
            live on;
            # sample play/publish handlers
            #on_play http://localhost:8080/on_play;
            #on_publish http://localhost:8080/on_publish;

            # sample recorder
            #recorder rec1 {
            #    record all;
            #    record_interval 30s;
            #    record_path /tmp;
            #    record_unique on;
            #}

            # sample HLS
            #hls on;
            #hls_path /tmp/hls;
            #hls_sync 100ms;
        }

        # Video on demand
        #application vod {
        #    play /var/Videos;
        #}

        # Video on demand over HTTP
        #application vod_http {
        #    play http://localhost:8080/vod/;
        #}
    }
}