Monday, February 3, 2025

Sending commands to OBS using WebSockets

Send commands to Websockets using OBScommander

I'm using "Nutty's Official OBS Commander - NOOBS CMDR"  

This program will create .bat file that, upon execution, would allow you to control elements of another OBS instance (or on the same machine just via bat files).  

In my example I have 2 OBS instances, the first one is capturing a hockey game then sending the video to a second OBS instance which putting on the scoreboard graphics.

When the first OBS goes into replay, I want to clear the graphic, so I tell the second OBS to go from scene "Game" to scene "Replay" which are identical, except the Replay scene has no graphics.

1: First turn on websockets on the graphics OBS, set a password.  I used "Password20"


2.  I setup two scenes
    
One is called "Game" and this is the normal game.  Which contains the HDMI input from the switcher and the graphics overlay

The second one is called "Replay" which doesn't have any graphics, just the HDMI input


I created 2 .BAT files that looked like this on my computer capturing the hockey game.  By double clicking on these bat files, I could set my graphics on and off.

graphic-off.bat contained

OBSCommand.exe /server=IPofGraphicsOBS:4455 /password="Password20" /scene="Replay"

graphic-on.bat   contains this:

OBSCommand.exe /server=IPofGraphicsOBS:4455 /password="Password20" /scene="Game"



Now the OBS instance capturing the hockey game, Advanced Scene Switcher was installed.

This program can automate numerous tasks within OBS, and in this case, when the REPLAY hotkey (F9) is pressed, it watches for that button to be pressed and runs the file "graphic-off".  When the replay is done, the hotkey is pressed (F12) and AdvSS runs "graphic-on" file which tells the graphics OBS to switch to the scene "game"

Once you install it, go into that OBS instance and we'll configure it.  On my switcher I have 2 camera inputs and a Replay input from our instant replay machine.


I started up Advanced Scene Switcher to make it active


On the Macro tab I created a new macro, and this is what the configuration is:

The first macro, when it detects that the "Instant Replay" scene is live, will run the "graphics-off.bat" file, which will tell the graphics computer to switch to the scene with no graphics.




Then created a second one, this time we select "IF NOT" in the first section.
This says, "if the active output is NOT instant replay, send a command to turn the graphics back on."



Now you can toggle back and forth between your scenes and graphics will turn on and off.


No comments:

Post a Comment

Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.