xObsSimpleHttpControl - Simple HTTP/URL control for OBS

xObsSimpleHttpControl - Simple HTTP/URL control for OBS v1.1

YorVeX

Member
YorVeX submitted a new resource:

xObsSimpleHttpControl - Simple HTTP/URL control for OBS - Remote interface to control any number of OBS instances using simple HTTP/URL calls

xObsSimpleHttpControl

D̲e̲s̲c̲r̲i̲p̲t̲i̲o̲n̲
This tool acts as a simple HTTP gateway to the obs-websocket interface. The idea is that more tools can trigger simple HTTP interfaces instead of opening a websocket connection and sending JSON. Also from user perspective it's easier to use, because formatting URL query parameters is a bit easier to do than formatting JSON.
In theory every request that is listed here can be sent...

Read more about this resource...
 

YorVeX

Member
Since this is my own use case here's an example of how this can be used from Node-RED for doing a scene change in OBS. I like to have everything as a separate item because with this modular approach it's easy to create new combinations from this: invoke a difference OBS instance, a different method, with different parameters, everything can be just put together with a few clicks. The scene change call looks like this:
1627416723209.png

From left to right: "My Scene Name" is the input parameter, this is the scene we want to switch to. "SetCurrentScene" is the method we want to invoke. "OBS Main" is the name of the OBS instance we want to address. And "OBS Control" is a "http request" node that does the actual HTTP call. To have it this modular way it has "obs.method" and "obs.instance" configured as dynamic request parameters, the settings look like this:
1627416914247.png


The item "OBS Main" sets the parameter "obs.instance" like this:
1627416971637.png


The item "SetCurrentScene" sets the parameter "obs.instance" like this:
1627417029641.png


This part will be the same for all calls to the tool, just change the name of the method and the instance you want to call according to your needs. Then, many methods need addtional parameters. You have seen that we configured the "http request" node to get query parameters from the payload, so for SetCurrentScene we need to put the "scene-name" parameter into the payload like this:
1627417123476.png


Note that this string is enclosed in quotation marks. This is important, since the corresponding JSON parameter for obs-websocket is a string and therefore needs the quotes (unlike numbers or boolean values).
This is just for the sake of this example, of course you can also dynamically feed in the scene name from other logics you might have. In this case make sure that you don't have any remaining payload items from previous nodes, as they would also be sent to OBS, causing the call to be rejected.
And again, remember the quotation marks. If you get the scene name from a field that doesn't have them, you can easily add them using a mustache syntax template node like this:
1627417458859.png


And that's it. If you understood how this works you should easily be able to do all other possible obs-websocket calls from Node-RED now just by copying and modifying these nodes.

Of course if you prefer you can do all the parameter settings in one single change node. I personally prefer this modular approach, since this way I can easily put new combinations of these together, also it automatically is a good visual documentation of what is done. But that's up to you...
 

YorVeX

Member
Here's another Node-RED use case of mine for reacting on events from OBS:
1627417940881.png

For this you configure an "http in" node like this:
1627417970975.png

Don't forget the "http response" node that returns the 200 status code, otherwise all xObsSimpleHttpControl webhook calls to this Node-RED endpoint would run until they time out and block a thread in the mean time.

Your webhook URL in the xObsSimpleHttpControl config would look like this (assuming Node-RED and xObsSimpleHttpControl are running on the same machine):
Code:
<WebhookUrl>http://127.0.0.1:1880/stream/obs-event</WebhookUrl>
I'd recommend to also configure a filter for the webhook if you only need a select few events, so that xObsSimpleHttpControl doesn't send lots of events to Node-RED only to have them discarded there, it will save you some resources for both xObsSimpleHttpControl and Node-RED.

In my example above I want to find out about scene switches from "TransitionBegin" events, because unlike "SwitchScenes" this event is already sent when the scene switch starts so we get it at the earliest possible point and independently from transition timings (that might change in the future). All we need is this simple switch node for the event parameter, configured like this:
1627418519145.png


Now from here some Node-RED magic happens. Since xObsSimpleHttpControl sends the original obs-websocket JSON data with Content-Type set to "application/json" Node-RED will automatically parse the JSON contents and provide the data as simple payload fields. You can read about this here.

Because of this you can now simply access the name of the scene OBS was switched to from the "payload.to-scene" field (or the "payload.from-scene" field if you want to know which scene it was coming from). With this you could build a flow that changes the scene in "OBS Main" to the same scene that you got from another OBS instance via the webhook. Or automatically mute your mic (with a call to SetMute) whenever OBS switches to a scene named "AFK" and unmute again when you switch to any other scene.

Let me know if this was helpful to you, I am usually very busy and rarely take the time and effort to document such things for other people so I'd be happy to know it wasn't in vain. Also please understand that this is only to give you a starting point, I won't be able to support your further Node-RED ventures here.
 

YorVeX

Member
For Chataigne I can't go into the same level of detail, but you can read here about how HTTP requests and query parameters are handled.

Also using this from VoiceAttack could be interesting, switching to AFK scene automatically just by saying "I am going AFK now", anyone? ;-)
I am no expert on VoiceAttack but managed to get an HTTP call working by a simple trick:
1627420078427.png


Now VoiceAttack has the option to get a text value from an URL, which is what we use to call xObsSimpleHttpControl:
1627421298825.png


The variable is just a dummy, since we don't really need the return value (in most cases it should just be the text "OK").

I don't know whether dynamic parameters can be put in there, but that's probably just me not knowing VoiceAttack very well. Feel free to share your experience here.
 

YorVeX

Member
@YorVeX -- Can you provide a URL example for controlling OBS that is running on a different computer within the same network?
xObsSimpleHttpControl is meant to be run only once on one machine and from there access OBS instances that can be on the same machine as well as on remote machines, so the only thing that changes in the URL is the name of the OBS instance and the configuration behind that instance defines whether it is accessed on the local machine or remotely. Local machines have the address "localhost", remote machines a remote computer name or remote IP address in your network.

Let's say you run xObsSimpleHttpControl on the computer you are currently working on, one OBS instance on the same machine (let's call it "OBS Local") and another OBS instance on a remote machine with the IP address 192.168.100.2 in your network (which we call "OBS Other Machine").

Your config then could contain this:

XML:
<Instance>
    <Name>OBS Local</Name>
    <WebsocketAddress>localhost</WebsocketAddress>
    <WebsocketPort>4444</WebsocketPort>
    <WebsocketPassword>secret</WebsocketPassword>
</Instance>
<Instance>
    <Name>OBS Other Machine</Name>
    <WebsocketAddress>192.168.100.2</WebsocketAddress>
    <WebsocketPort>4444</WebsocketPort>
    <WebsocketPassword>secret</WebsocketPassword>
</Instance>

Now using the original URL example to change the scene to "Game" on the local OBS instance you would call this:
http://localhost:57297/xObsSimpleHttpControl/OBS Local/SetCurrentScene?scene-name="Game"

To change the scene to "Game" on the remote OBS instance you would call:
http://localhost:57297/xObsSimpleHttpControl/OBS Other Machine/SetCurrentScene?scene-name="Game"

If xObsSimpleHttpControl itself is running on the 192.168.100.2 remote machine you would replace "localhost" with the address of the remote machine, e.g.:
http://192.168.100.2:57297/xObsSimpleHttpControl/OBS Local/SetCurrentScene?scene-name="Game"

If you want to access xObsSimpleRemoteHttpControl remotely be sure to read the comment for the <Prefix> configuration in the xObsSimpleHttpControl.conf file, you need to change the prefix config and run the command given there in an admin CMD window, otherwise the tool won't have the necessary permission to listen for remote calls.
 
Still confused as to what to configure/run on which computer.

I spent quite bit of time workingg with it last nite, and was only able to get remote control to work from a browser running on the same computer I am running OBS on.
 

YorVeX

Member
Still confused as to what to configure/run on which computer.

I spent quite bit of time workingg with it last nite, and was only able to get remote control to work from a browser running on the same computer I am running OBS on.

Feel free to share details about your setup and your current config - remember to remove any passwords beforehand or temporarily set more simple ones while testing. Maybe I can see what the problem is.

I am currently using it to control 4 OBS instances, 3 on the same machine and one on a remote machine. So I am sure it's possible with this tool ;-)
 
I wonder if it is because I am within a corporate network, and p2p connections are not allowed.

I cannot even make use of the remote debug switch feature used when lauching OBS….It can work to go to localhost:9222, for instance, in a browser running on the same computer as OBS, but cannot go to <pcname>:9222 from another computer.
 

YorVeX

Member
I wonder if it is because I am within a corporate network, and p2p connections are not allowed.

I cannot even make use of the remote debug switch feature used when lauching OBS….It can work to go to localhost:9222, for instance, in a browser running on the same computer as OBS, but cannot go to <pcname>:9222 from another computer.

Corporate network could indeed be in the way here. I assume you have made sure there is no software firewall in the way? Then it could very well be hardware firewalls or there is simply no routing configured for this port between the two computers.
 

CConvey

New Member
Thanks very much for posting this software! I'm planning to buy a StreamDeck to control OBS, and I hadn't yet worked out how I was going to make StreamDeck button presses trigger OBS scene changes.
 

YorVeX

Member
Thanks very much for posting this software! I'm planning to buy a StreamDeck to control OBS, and I hadn't yet worked out how I was going to make StreamDeck button presses trigger OBS scene changes.
Stream Deck can do this out of the box, as long as OBS is running on the same computer that the Stream Deck is connected to and their software is running on. If you want to control OBS on a remote computer from your Stream Deck, then yes, this tool will help to easily bridge that gap.
 

KeepKool

New Member
I keep getting unknown payload type:16 . And im seeing 1 FPS with no recording or streaming. I cant solve this problem and need your help
Stream Deck can do this out of the box, as long as OBS is running on the same computer that the Stream Deck is connected to and their software is running on. If you want to control OBS on a remote computer from your Stream Deck, then yes, this tool will help to easily bridge that gap.
 

Attachments

  • 2021-10-09 12-45-44.txt
    346 KB · Views: 70

nicwillu

New Member
Hi there @YorVeX . Fantastic work! I just have one problem. I get this error when trying to send a webhook to my automation platform. Tried googling a bit but didn't become any smarter.
Code:
Webhook URL: https://hook.eu1.make.com/ja2fbrfdkfhcc7440uosm16gke2hhccg (<- test webhook. no worries)
WebException: The request was aborted: Could not create SSL/TLS secure channel.

   at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
   at System.Net.WebClient.UploadString(Uri address, String method, String data)
   at XBase.xObsSimpleHttpControl.NotificationIcon.<>c__DisplayClass9.<.ctor>b__6()

I am running .NET 4.8 btw with W11
 
Last edited:

YorVeX

Member
Hi there @YorVeX . Fantastic work! I just have one problem. I get this error when trying to send a webhook to my automation platform. Tried googling a bit but didn't become any smarter.
Code:
Webhook URL: https://hook.eu1.make.com/ja2fbrfdkfhcc7440uosm16gke2hhccg (<- test webhook. no worries)
WebException: The request was aborted: Could not create SSL/TLS secure channel.

   at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
   at System.Net.WebClient.UploadString(Uri address, String method, String data)
   at XBase.xObsSimpleHttpControl.NotificationIcon.<>c__DisplayClass9.<.ctor>b__6()

I am running .NET 4.8 btw with W11
Sorry for the late response, somehow I missed the notification for a new posting here. I will release v1.1 soon, which should address this issue. Full changelog of v1.1 currently is:
  • sped up program start-up in situations where not all configured OBS instances are reachable
  • added Get mode that will 1. wait for the response 2. return the raw JSON response from OBS
  • URL parameters now use UTF-8 encoding
  • updated URL call encryption standard to TLS v1.2, fixing "Could not create SSL/TLS secure channel" errors
 
Top