All Projects → 715209 → nginx-obs-automatic-low-bitrate-switching

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

Licence: MIT license
Simple app to automatically switch scenes in OBS based on the current bitrate fetched from the NGINX stats page.

Programming Languages

rust
11053 projects
Svelte
593 projects
XSLT
1337 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to nginx-obs-automatic-low-bitrate-switching

OBS-ChatSpam
Python script for OBS Studio that posts messages in Twitch chat
Stars: ✭ 26 (-84.43%)
Mutual labels:  twitch, streaming, obs
Firebot
A powerful all-in-one bot for Twitch streamers
Stars: ✭ 162 (-2.99%)
Mutual labels:  twitch, streaming, twitch-bot
OxidizeBot
High performance Twitch bot in Rust
Stars: ✭ 123 (-26.35%)
Mutual labels:  twitch, twitch-bot
simple-obs-stt
Speech-to-text and keyboard input captions for OBS.
Stars: ✭ 89 (-46.71%)
Mutual labels:  twitch, obs
twitch-observer
Turn Twitch chatter into Python events
Stars: ✭ 25 (-85.03%)
Mutual labels:  twitch, twitch-bot
marv
Marv your Swiss streaming tool!
Stars: ✭ 149 (-10.78%)
Mutual labels:  twitch, obs
Lagertha
A UI/UX redesign of the popular Twitch-bot PhantomBot
Stars: ✭ 10 (-94.01%)
Mutual labels:  twitch, twitch-bot
StarCraft-Casting-Tool
StarCraft Casting Tool is a free to use open source program that makes casting StarCraft 2 simple while increasing the production value substantially by providing a match grabber and various sets of animated icons and browser sources to be shown to the viewer.
Stars: ✭ 17 (-89.82%)
Mutual labels:  twitch, streaming
CounterStrike-GlobalOffensive-LiveStat-for-OBS-Studio
Showing you LIVEstats of CS:GO in your Stream like OBS-Studio while playing/streaming.
Stars: ✭ 24 (-85.63%)
Mutual labels:  twitch, obs
twitch-irc-rs
Twitch IRC library for the Rust programming language
Stars: ✭ 58 (-65.27%)
Mutual labels:  twitch, twitch-bot
TwitchPy
This is a package you can use to connect with the Twitch API, manage a channel, create bots, etc
Stars: ✭ 22 (-86.83%)
Mutual labels:  twitch, twitch-bot
PhantomBotDE
PhantomBotDE ist ein aktiv Entwickelter interaktiver Open Source Twitch Bot mit einer lebendigen Community welche Unterhaltung und Moderation für deinen Kanal bietet, dieser erlaubt dir dich auf das was wirklich zählt zu Konzentrieren - dein Spiel und deine Zuschauer.
Stars: ✭ 24 (-85.63%)
Mutual labels:  twitch, twitch-bot
Twitch-View-Bot
First open-source really working view bot for Twitch
Stars: ✭ 63 (-62.28%)
Mutual labels:  twitch, twitch-bot
TwitchMarkovChain
Twitch Bot for generating messages based on what it learned from chat
Stars: ✭ 87 (-47.9%)
Mutual labels:  twitch, twitch-bot
streamlabs-chat
Free customizable theme, template, custom coded CSS for Twitch, Streamlabs, Streamelemens chat box widget & overlay.
Stars: ✭ 59 (-64.67%)
Mutual labels:  twitch, obs
twitchtube
Twitch YouTube bot. Automatically make video compilations of the most viewed Twitch clips and upload them to YouTube using Python 3.
Stars: ✭ 398 (+138.32%)
Mutual labels:  twitch, twitch-bot
Twitch-Farmer
A bot that helps you to get more followers on Twitch
Stars: ✭ 124 (-25.75%)
Mutual labels:  twitch, twitch-bot
music-id
🚀 Music ID for Twitch (TwitchMusicID) is a Chatbot which automatically identifies music in the background of Twitch Streams, VODs, and Clips.
Stars: ✭ 49 (-70.66%)
Mutual labels:  twitch, twitch-bot
Streamlink Twitch Gui
A multi platform Twitch.tv browser for Streamlink
Stars: ✭ 2,059 (+1132.93%)
Mutual labels:  twitch, streaming
Streamlabs Obs
Free and open source streaming software built on OBS and Electron.
Stars: ✭ 3,473 (+1979.64%)
Mutual labels:  twitch, streaming

NOALBS

Simple app to automatically switch scenes in OBS Studio/OBS.Live based on the current bitrate fetched from the server stats.


NOALBS is used as a DIY tool to have your OBS Studio/OBS.Live auto switch scenes when you are either in a LOW bitrate situation or if your source disconnects completely.

Similar Solutions / Paid Services

Don't feel like setting this all up by yourself? Check out these links for similar solutions/paid services:

Do you offer a similar solution or paid service? Want your link here? Message b3ck#3517 on Discord

Quick Start

Chat Commands

This script gives you the option to enable some simple chat commands to help you manage your stream from your own Twitch chat, here is how to use them:

Please note: Admins are all the users in the admins array in chat config section, MODs are all of your MODs, and Public is anyone in your chat.

Default Role Command Description Example
Admins !start on-demand command to start streaming in OBS. !start
Admins !stop on-demand command to stop streaming in OBS. !stop
Admins !record on-demand command to toggle recording in OBS. !record
Admins !alias (alias) (command) add an alias for a command. !alias ss switch
Admins !alias rem (alias) removes an alias for a command. !alias rem ss
Admins !switch (scene) switches to the provided SCENE (fuzzy match). !switch INTRO
Admins !live switch to the live scene. !live
Admins !privacy switch to the privacy scene. !privacy
Admins !starting switch to the starting scene. !starting
Admins !ending switch to the ending scene. !ending
Admins !noalbs prefix (prefix) change noalbs command prefix. !noalbs prefix #
Admins !noalbs retry (value) changes the retry value for the switcher. !noalbs retry 5
Admins !noalbs lang (value) changes the chat response language. !noalbs lang zh_tw
MODs !trigger (value) changes the low bitrate threshold to the defined value. !trigger 800
MODs !otrigger (value) changes the offline bitrate threshold to the defined value. !otrigger 200
MODs !rtrigger (value) changes the RTT threshold to the defined value. !rtrigger 2000
MODs !sourceinfo gives you details about the SOURCE in chat. !sourceinfo
MODs !fix tries to fix the stream. !fix
MODs !refresh tries to fix the stream. !refresh
Public !bitrate returns the current bitrate. !bitrate

You can also enable/disable certain features from chat, see below:

Default Role Command Description Example
Admins !public (on/off) enables/disables the use of Public commands. !public off
Admins !mod (on/off) enables/disables the use of MOD commands. !mod on
Admins !notify (on/off) enables/disables the notifications in chat. !notify off
Admins !autostop (on/off) enables/disables the auto stop feature when you host/raid. !autostop on
Admins !noalbs (start/stop) NOALBS start/stop switching scenes. !noalbs stop
Admins !noalbs instant toggle instant switching from offline scene. !noalbs instant

Configure NOALBS

Open the .env file. If you have a custom Twitch account created for a bot fill in your Twitch Account bot username and oauth.

Use https://twitchapps.com/tmi to get your oauth from Twitch.

We recommend using your main Twitch BOT account for this, but if you do not have a Twitch Bot account just use your Main Twitch Account.

The config.json file holds all the user configurations.

Stream servers section

Currently NOALBS supports NGINX, Nimble, Node Media Server, SRT Live Server, BELABOX and OBS Sources. You can have as many servers as you want to use in the config.

Example stream server object:

{
  "streamServer": {
    "type": "Nginx",
    "statsUrl": "http://localhost/stats",
    "application": "publish",
    "key": "live"
  },
  "name": "nginx",
  "priority": 0,
  "overrideScenes": {
    "normal": "normal",
    "low": "low",
    "offline": "offline"
  },
  "dependsOn": null,
  "enabled": true
}
  • streamServer: Replace this with the server you would like to use
  • name: A unique name to distinguish the server
  • priority: Decides which stream server to monitor when multiple are online. 0 is consired the highest.
  • overrideScenes: Optional field to override the default scenes
  • dependsOn: Optional field explained here

Stream server objects

Using NGINX

  "streamServer": {
    "type": "Nginx",
    "statsUrl": "http://localhost/stats",
    "application": "publish",
    "key": "live"
  },

Using an external Node-Media-Server

"streamServer": {
  "type": "NodeMediaServer",
  "statsUrl": "http://localhost:8000/api/streams",
  "application": "publish",
  "key": "live",
  "auth": {
    "username": "admin",
    "password": "admin"
  }
},
  • auth: Optional field

Using Nimble Streamer Server (with SRT protocol)

Nimble must have API access enabled and be configured as a SRT receiver - see "Set up receiving of SRT" and have an outgoing stream ("Add outgoing stream" on same page)

"streamServer": {
  "type": "Nimble",
  "statsUrl": "http://nimble:8082",
  "id": "0.0.0.0:1234",
  "application": "live",
  "key": "srt",
},
  • statsUrl: URL to nimble API
  • id: UDP listener ID (Usually IP:Port)
  • application: Outgoing stream "Application Name"
  • key: Outgoing stream "Stream Name"

Switches on low bitrate or high RTT (high RTT seems to be a more accurate way of determining if the stream is bad with this) You can change the high RTT trigger value inside config.json


Using SLS (SRT-LIVE-SERVER)

Big Thanks to oozebrood, matthewwb2, and kyle___d for all of the hard work they've put into getting SRT to the masses! If you're using either Matt's modified version or my edit of Matt's version of SLS then follow this section;

"streamServer": {
  "type": "SrtLiveServer",
  "statsUrl": "http://localhost:8181/stats",
  "publisher": "publish/live/feed1"
},
  • stats: URL to SLS stats page (ex; http://localhost:8181/stats )

  • publisher: StreamID of the where you are publishing the feed. (ex; publish/live/feed1 )

  • Publisher, what is a publisher? it's a combination of domain_publisher/app_publisher/<whatever-you-want>.

    • So if your domain_publisher was "uplive.sls.com", and your app_publisher was "live", it would be uplive.sls.com/live/<whatever-you-want>.
    • You could literally call you domain_publisher 'billy', app_publisher 'bob', and then set your streamid (publisher) to 'billy/bob/thorton' if you wanted to.
    • Publisher is also what you entered in the config under default_sid. Unless you are streaming to a different 'StreamID' of course, ex; publish/live/tinkerbell.

See Example Below from the sls.conf file in the SLS main directory:

image

So in actuality your 'publisher' is your default StreamID, like in the example above it's billy/bob/thorton.

Switches on low bitrate or high RTT (high RTT seems to be a more accurate way of determining if the stream is bad with this) You can change the high RTT trigger value inside config.json:

How do I publish to the SLS Server?

see HERE

How do I pull the SRT feed into OBS?
  • Add Media Source
  • Un-check Local File
  • Make sure Restart playback when source becomes active is checked.
  • Change Network Buffering to 1 MB
  • In the "Input" field enter in: srt://<SERVER-IP>:<PORT>/?streamid=<PUBLISHER>
    • Using the example from the above image, it would be something like this if you are using SLS on the same machine: srt://localhost:30000/?streamid=jojo/bob/thorton
  • In the Input Format field enter in: mpegts
  • Change Reconnect Delay to 3S (Three Seconds)
  • Make sure Show nothing when playback ends is checked.
  • Check Close file when inactive
  • Optional: If your streams color looks washed out change your YUV Color Range to Partial
  • Sidenote: Do not Use Use hardware decoding when available, Apply alpha in linear space, or Seekable, As I have only ran into issues with these options enabled.

Below is an example when used with a BelaBox Reciever:

image

Remember this is just an example, your ports and streamid may differ.


Using BELABOX cloud

  "streamServer": {
    "type": "Belabox",
    "statsUrl": "http://belabox-stats-url/yourkey",
    "publisher": "yourkey"
  },

You should be able to find the details in your BELABOX cloud account.


Using an OBS Source

  "streamServer": {
    "type": "Obs",
    "source": "Media/VLC Source"
  },

Depends on

When a dependsOn field is found, monitor the status of the given server. If that server goes offline the backupScenes will be used.

"dependsOn": {
  "name": "nginx",
  "backupScenes": {
    "normal": "Scene 3",
    "low": "low",
    "offline": "Scene 2"
  }
}
  • name: The exact name this stream server depends on
  • backupScenes: Scenes that will be used when the depended on server is offline

Building from source

Download and install:

Then:

  • git clone <repository-url> or download from GitHub.
  • cd <repository-name>
  • cargo run or cargo run --release

FAQ

Need additional help?

You can always contact us on discord @ b3ck#3517 or 715209#0600 and we'll do our best to help out.

I want to keep using the old version

You can find the old NOALBS version in the master branch.

NGINX Setup

If you already have NGINX-RTMP server

  • Replace your nginx.conf with the one given here.
  • Put stat.xsl in your nginx html folder.

Otherwise here is a Windows version of NGINX+RTMP Server

  • Hosted on Github
  • Everything is ready to go inside this zip, just extract and click on the nginx_start.bat file to start NGINX, you can use nginx_stop.bat to stop NGINX. HTTP server runs on Port 80, RTMP server runs on 1935, if you need to edit the config file it's in the /conf folder, named nginx.conf.

How to publish to your NGINX RTMP Server

Using the default config where the server is listening on port 1935 and the name of the application in NGINX is publish;

(example config, do not copy)

rtmp {
    server {
        listen 1935;
        (...)
        
        # Stream to "rtmp://IPHERE/publish/live".
        application publish {
            live on;
            (...)
        }
    }
}
  • If the app or device requires the key separately put rtmp://(SERVER-IP):1935/publish in the RTMP URL and live in the key.
  • Otherwise if the app or device doesn't require the key separately put rtmp://(SERVER-IP):1935/publish/live in the RTMP URL.

Most of these rules apply to the rest of the other types of servers;

  • RTMP will usually have an application and a key.
  • SRT will use a publisher ID or streamid, some applications or devices will only require your server IP and PORT;
    • Example; srt://(SERVER-IP):30000 but if it the app or device supports streamid it will always be separate.

Either way, pay close attention to your app or device requirements, as you will need to setup accordingly to them and your configuration on the server.


How to pull RTMP stream into OBS

Update your OBS to v26+ and follow the steps below:

1.) In OBS create the following scenes:

  • LIVE, LOW, BRB, REFRESH
  • I highly recommend creating a STARTUP & PRIVACY scene, the STARTUP scene can contain whatever you want to start your stream on and then switch to LIVE when you're ready, the PRIVACY scene can be whatever you want to put the stream on when you need privacy, the main thing is that it's out of NOALBS scope and won't automatically switch scenes.
  • The normal flow is to have your OBS on STARTUP when you start stream and when you're ready either you or an instructed MOD can !switch LIVE, when you need privacy use !switch PRIVACY.

2.) In your LIVE scene, add a 'Media Source', match the image below:

image

  • Right click on the 'Media Source' > Transform > Stretch to screen (this will stretch the video source no matter the resolution, ex; 480p, 720p, 1080p etc.)

3.) Copy and Paste(Reference) the 'Media Source' from the LIVE scene into your LOW scene.

  • Do the same transformation procedure from step (2).

4.) Go over all of your scenes and make them your own.


How to run with multiple users

In the .env file add the line CONFIG_DIR=configs where configs is the folder that holds all the config files. The name of the config is ignored so you can name it anything you want.


Help it won't change scenes

It will only change scenes when OBS is set on a scene that's in the config.
(This is so that it wont change when you are on for example your 'intro' or 'locked-brb' scene)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].