NOALBS / nginx-obs-automatic-low-bitrate-switching

Simple app to automatically switch scenes in OBS based on the current bitrate fetched from the NGINX stats page.
http://noalbs.com
MIT License
358 stars 77 forks source link

Update nginx.conf #113

Closed DigibitDK closed 2 years ago

DigibitDK commented 2 years ago

If something is already defined in server-settings, you don't need to add them to application as well, since server-settings will act as global for all applications. (The remaining applications-settings can be global server-settings as well)

Blackwolf8202 commented 2 years ago

With this small change, it doesn't work to have "two" connections on the 1935. Tried downloading 2.7.1 and tried having two but the second camera refused to start and then I still did it right from 2.7.0 only that I removed the two lines at the bottom as you have changed it. But had to go back to 2.7.0 again.

DigibitDK commented 2 years ago

@Blackwolf8202

Not exactly sure what you mean. Removing the two lines in the config makes no changes to how the RTMP-server works. Its just a double confection. Connecting to streams to same application and key, at the same time, will never work. You can just add the two lines again, and keep 2.7.1 if that should be the reason :)

I have 30+ users on the server, all with each own application. Changes made in server-config will affect all applications. Changes made in application will only affect selected application. Its kind of descried in 'nginx rtmp directives' as well.

Blackwolf8202 commented 2 years ago

worker_processes 1;

events { worker_connections 1024; }

http { sendfile off; tcp_nopush on; directio 512; include mime.types; default_type application/octet-stream; ignore_invalid_headers on; log_format compression '';

server {
    listen      80;
    server_name localhost;
    gzip on;
    access_log logs/http-access.log compression;

# These headers will help with Access Control Origin Errors, it might be overkill but it works.
    location / {
        add_header 'Cache-Control' 'no-cache';

        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain; charset=utf-8';
            add_header 'Content-Length' 0;
            return 204;
        }

        if ($request_method = 'POST') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
        }

        if ($request_method = 'GET') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
        }
    }

# Location of your RTMP Stats page.
    location /stat {
        if ($request_method = "GET") {
            add_header "Access-Control-Allow-Origin"  *;
        }

        rtmp_stat all;
    # The name of the stats page stylesheet.
        rtmp_stat_stylesheet /stat.xsl;
    }

    location /stat.xsl {
        root html; # Location of stat.xsl
    }

    location /control {
        rtmp_control all;
    }
}

}

rtmp { log_format compression '';

server {
    listen 1935;
    ping 30s;
    notify_method get;
    chunk_size 8192;
    ack_window 8192;
    sync 4ms;
    interleave on;
    access_log logs/rtmp-access.log compression;

    # Stream to "rtmp://IPHERE/publish/live".
    application publish {
        live on;
        wait_video on;
        wait_key on;
        exec_options on;
        publish_notify on;
        play_restart on;
        drop_idle_publisher 4s;
        idle_streams off;
        sync 4ms;
        interleave on;
    },
    application publish2 {
        live on;
        wait_video on;
        wait_key on;
        exec_options on;
        publish_notify on;
        play_restart on;
        drop_idle_publisher 4s;
        idle_streams off;
        sync 4ms;
        interleave on;
    }
}

}

Blackwolf8202 commented 2 years ago

Well, if I remove the two lines, only camera 1 works, not two at all, if you look at the bottom, you'll understand what I mean =)

Blackwolf8202 commented 2 years ago

Otherwise, please help me how to write about it in that case

DigibitDK commented 2 years ago

That's strange. Your config looks fine to me, and should work with or without the lines. Strange thing is, that most of my applications is empty, and looks more or less like this:

application publish1 {} application publish2 {}

All my settings is defined in rtmp { Server { ... and acks as global unless something is defined in application to override global.

Just to be sure, if you install 2.7.1, and manual add the lines, then it works again?

I can test you config some time next week, since im down with corona at this point. Just to see if I experience the same.

DigibitDK commented 2 years ago

Your config, is that a working config, or non-working config?

Blackwolf8202 commented 2 years ago

@DigibitDK That's a working configuration I have. And it worked damn well for the latest version that has been released, but not for v 2.7.1 or then for 2.7.2 if you want two outputs. Sorry for the late reply, I've been working a lot. Hope you feel well again =)

DigibitDK commented 2 years ago

First thing I notice is, that you have a , that should not be there. 2022-09-16 02_26_08-Window

DigibitDK commented 2 years ago

This is based on the updated nginx-conf provided with Noalbs. (With the extra lines removed)

2022-09-16 02_41_09-Window

DigibitDK commented 2 years ago
rtmp {
    log_format compression '';

    server {
        listen 1935;
        ping 30s;
        notify_method get;
        chunk_size 8192;
        ack_window 8192;
        sync 4ms;
        interleave on;

        # Example: stream to "rtmp://IPHERE/publish/live".
        application publish {
            live on;
            wait_video on;
            wait_key on;
            exec_options on;
            publish_notify on;
            play_restart on;
            drop_idle_publisher 4s;
            idle_streams off;
        }
        application publish2 {
            live on;
            wait_video on;
            wait_key on;
            exec_options on;
            publish_notify on;
            play_restart on;
            drop_idle_publisher 4s;
            idle_streams off;
            }
         }
}
Blackwolf8202 commented 2 years ago

Aha sorry i dont see that, my bad 🤣👍

Den fre 16 sep. 2022 02:44Michael @.***> skrev:

rtmp { log_format compression '';

server {
    listen 1935;
    ping 30s;
    notify_method get;
    chunk_size 8192;
    ack_window 8192;
    sync 4ms;
    interleave on;

    # Example: stream to "rtmp://IPHERE/publish/live".
    application publish {
        live on;
        wait_video on;
        wait_key on;
        exec_options on;
        publish_notify on;
        play_restart on;
        drop_idle_publisher 4s;
        idle_streams off;
    }
    application publish2 {
        live on;
        wait_video on;
        wait_key on;
        exec_options on;
        publish_notify on;
        play_restart on;
        drop_idle_publisher 4s;
        idle_streams off;
        }
     }

}

— Reply to this email directly, view it on GitHub https://github.com/715209/nginx-obs-automatic-low-bitrate-switching/pull/113#issuecomment-1248792614, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLHJP7R47E76QP74VMRKCTV6O7HRANCNFSM55OHNK7Q . You are receiving this because you were mentioned.Message ID: <715209/nginx-obs-automatic-low-bitrate-switching/pull/113/c1248792614@ github.com>