Okay, I think I'm ready to ask now. Is there a way, using macros, to make a Slave instance follow a Master one, on the same machine? As I've said before, OBS 28's built-in WebSocket insists on using the same settings for all instances, which means that I can't easily separate them like I could with a previous version and a separate WebSocket plugin.
I think that this might a good start?:
Master:
The idea here is to send the name of the new scene as an event, whatever that scene is. Like the End of Media macro, this also needs to still work after I add and remove a bunch of scenes, without coming in here to fix it back up again.
I don't remember seeing any documentation about how to include non-hardcoded stuff in the macros' text boxes. This is the bash way of doing it, which I was in the mindset of after building the setup script, but there are other ways that scripted languages do it too. Which, if any, is it?
A help button here in the UI would be nice, to say how to do that. Or a drop-down that lists all the possible variables to insert. (choosing one would also show how to do it manually, so the help button is probably not needed then)
Slave:
Connect to and listen for that event from the Master, and switch to the appropriate scene. All three of these macros are identical except for the {Camera|Feature|Voiceover} tags. (used by the name, regex, and scene)
If I understand correctly, this connection actually connects to both copies of OBS, since they both insist on using the same WebSocket settings, but the events that I'm looking for only come from one, and the receiving code is only in the other, so that works??? At least in theory?
I want to keep the Master as minimal as possible (nothing at all would be nice), since there could be several of those set up for different uses, and I want to minimize the number of things that can be erased by accident while customizing a new duplicate of it. The same Slave is used for all of them, unchanged, so it can be a (well-documented) mess if need be.
The way that my python script worked before, with two different WebSocket servers, is to register itself for the SwitchScenes event in the Master, and then run a set of regexes on the message.getSceneName(). Depending on which regex matches, it sends a request to the Slave to set the corresponding scene.
All of that happens without any logic at all in either instance of OBS, which leads me to hope that it might be possible with no Master macro at all, and to have everything on the Slave side. Just connect the Slave to that specific, existing event, not just the general server. (if it insists on connecting to both copies of OBS, then a simple rename of the Slave scenes should kill an infinite loop:
^Camera.*$ doesn't match
_Camera, for example)
As I've posted before, the complete python code for reference is:
Python:
#!/usr/bin/env python
import re
import sys
import subprocess
from obswebsocket import obsws, events, requests
wsSlv = obsws("localhost", 4456, "NotTheRealPassword!")
try:
wsSlv.connect()
except:
print("Error: Could not connect to OBS Slave")
sys.exit(-1)
def on_switch(message):
name = message.getSceneName()
if re.match("Camera.*", name):
wsSlv.call(requests.SetCurrentScene("Camera"))
if re.match("Feature.*", name):
wsSlv.call(requests.SetCurrentScene("Feature"))
if re.match("Voiceover.*", name):
wsSlv.call(requests.SetCurrentScene("Voiceover"))
wsMst = obsws("localhost", 4455, "NotTheRealPassword!")
wsMst.register(on_switch, events.SwitchScenes)
try:
wsMst.connect()
except:
try:
wsSlv.disconnect()
except:
pass
print("Error: Could not connect to OBS Master")
sys.exit(-2)
# Expect a dialog command and message, to be passed as arguments to this script
# Closing the dialog is taken as a shutdown command, so this doesn't return until then
subprocess.run(sys.argv[1:])
# Disconnect from both, if possible
# If not, don't worry about it; it probably is already
try:
wsMst.disconnect()
except:
pass
try:
wsSlv.disconnect()
except:
pass
sys.exit(0)
It doesn't really matter to me whether I use the python script, or do it all with macros, just as long as it works. So far, it doesn't yet, with up-to-date tools. An old version of this rig does it with the old File tab - Master writes the current scene name to a file, Slave reads the file and does the regexes - but I'd rather avoid the file altogether if I can, hence the python script for a later version and this question for another update.
Any ideas?