Advanced Scene Switcher

Advanced Scene Switcher 1.28.1

Kenshin9977

New Member
Could it maybe be that "yuzu-emu" requires additional arguments?
I am not familiar with this particular application at all unfortunately, but are you sure that you want to start the installer and not the application itself instead? (E.g. "yuzu.exe")
Well that's one application I found that has the same issue. I run into the same issue with python applications I packaged into an .exe using pyinstaller but it's easier to reproduce if I send you a binary you can easily and safely get thus the yuzu installer link.
I don't think it's missing any argument otherwise it wouldn't launch through a cmd terminal without extra args
 

Warmuptill

Active Member
Well that's one application I found that has the same issue. I run into the same issue with python applications I packaged into an .exe using pyinstaller but it's easier to reproduce if I send you a binary you can easily and safely get thus the yuzu installer link.
I don't think it's missing any argument otherwise it wouldn't launch through a cmd terminal without extra args
I think I understand what is happening.

The particular processes that are seemingly refusing to launch are likely trying to create files in the working directory of the process that created them.
As the calling process is OBS and is likely being run from a location with limited access rights, like C:\Program Files, creating files is in those directories is not allowed.
The processes likely can't handle this situation of not being able to create files and simply exit.

You could work around this problem by running OBS with administrative privileges as this will grand write access to those directories or run OBS from a different folder (e.g. in portable mode), but this is probably not a "good" solution.

The correct solution would be to set the working directory to a folder where files can be created without issues.
I added this option to the "Run" action in the build below:
CWD.PNG


Please let me know if this solves your observed issues with the "Run" action!
 

Rediflow

New Member
Let me know if you notice any further issues!
Installed it & set it up. Seems to be working (it changes the values that are supposed to be change).
I have to set-up a live test yet, to check if the sync settings are working, but I guess they are, as OBS shows the change correctly.
 

Kenshin9977

New Member
Please let me know if this solves your observed issues with the "Run" action!

I also think the program's context is the problem here. So I tried with yuzu_install and now it works. But it still doesn't with the program I made a repo and compiled a binary with pyinstaller for you to reproduce the issue:

You can compile the file yourself with pyinstaller using this command in a terminal:
Code:
pyinstaller --onefile hello_world.py

To install pyinstaller you just need python and then type the following command:
Code:
python -m pip install pyinstaller
 

Warmuptill

Active Member
I also think the program's context is the problem here. So I tried with yuzu_install and now it works. But it still doesn't with the program I made a repo and compiled a binary with pyinstaller for you to reproduce the issue:

You can compile the file yourself with pyinstaller using this command in a terminal:
Code:
pyinstaller --onefile hello_world.py

To install pyinstaller you just need python and then type the following command:
Code:
python -m pip install pyinstaller
Those kinds of executables are still being run as expected.
They only seem to behave differently depending on how they are started.
Only when you launch them by double clicking on them the console window shows up.
(I assume that was leading to the assumption that the file was not executed)

You can test this by writing to a file instead of trying to write to stdout using print().
Code:
with open("test.txt", "w") as f:
    f.write("asdf\n")
 

AaronD

Active Member
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:
Master Switcher.png

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:
Slave Switcher.png

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?
 

Kenshin9977

New Member
Those kinds of executables are still being run as expected.
They only seem to behave differently depending on how they are started.
Only when you launch them by double clicking on them the console window shows up.
(I assume that was leading to the assumption that the file was not executed)

You can test this by writing to a file instead of trying to write to stdout using print().
Code:
with open("test.txt", "w") as f:
    f.write("asdf\n")
Ok I see. But my issue now is that I want to start my program if it's not running. In order to do that I set the following condition
"If not process process_name is running" but I can't do that as the process isn't running for Windows.
Before 28.0 I could do that because my program would start in a separate window, now I can't.
 

Warmuptill

Active Member
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?
First of all, sorry about the delayed response - I somehow missed your message.

Unfortunately that is not supported yet.
I will likely go the bash way of specifying variables in text boxes once I get around to implementing this.

So at the moment you would have to manually specify each message for each scene on the master side instead of using the $CURRENT_SCENE placeholder.

Maybe I can whip up a first prototype on the weekend (I cannot guarantee it though).
If so I will let you know.

Ok I see. But my issue now is that I want to start my program if it's not running. In order to do that I set the following condition
"If not process process_name is running" but I can't do that as the process isn't running for Windows.
Before 28.0 I could do that because my program would start in a separate window, now I can't.
Maybe I am missing or misunderstanding something, but the "Process" condition should work independent of if an application has a GUI / window or not.
What prevents you from starting the application and checking for its process name?
 

AaronD

Active Member
Unfortunately that is not supported yet.
I will likely go the bash way of specifying variables in text boxes once I get around to implementing this.

So at the moment you would have to manually specify each message for each scene on the master side instead of using the $CURRENT_SCENE placeholder.

Maybe I can whip up a first prototype on the weekend (I cannot guarantee it though).
If so I will let you know.
I still think that this would be useful for a lot of things besides what I'm doing, and it would get me past another hurdle for the moment, so still do it regardless. But better for me, I think, and a lot of other things as well, would be to connect to a specific pre-existing event like my python script does, instead of just the entire server and leaving it at that. Would that also be possible?

(Or I guess if the pre-existing "event" is just a parsable string, then I could use a regex for it...if I could easily see what comes across to be able to write that regex. I don't really know how WebSockets work, beyond one project with an ESP32 and Node-RED that did just send bare strings across.)

And it still remains to be seen how WebSockets work with two simultaneous instances that insist on using the same settings, but I guess we'll get there soon enough.
 
Last edited:

serenmew

New Member
I've been having no luck with getting Or Not statements to work. For example if I have it checking for if a file is not 0, or a second file is not, It will not work How I expect it to. It will perform the macro if the first condition is satisfied but not the second.
 

Attachments

  • 27e7e62acdae39a77f3cc445c111b473.png
    27e7e62acdae39a77f3cc445c111b473.png
    21.5 KB · Views: 20

discharacter

New Member
Warmuptill submitted a new resource:

Automatic Scene Switching - Switches to specified scenes depending on which window is in focus



Read more about this resource...
Hello Warmup,

I've installed the advanced scene switcher, and it pulls up when I launch it. However, I don't see all the tabs that I saw in the old version. The only tabs I have are "General" and "Macro"

I'm trying to make a simple scene switch, where Scene 1 switches to Scene 2 after 30 seconds. Then Scene 2 to Scene 3 after 30 seconds. Finally, switch from Scene 3 back to Scene 1 after 30 seconds, and repeat.

Very simple, but I'm having trouble doing it with this new version of scene switcher. Do I need to use the Macros tab? If so, how?
 

discharacter

New Member
Hello Warmup,

I've installed the advanced scene switcher, and it pulls up when I launch it. However, I don't see all the tabs that I saw in the old version. The only tabs I have are "General" and "Macro"

I'm trying to make a simple scene switch, where Scene 1 switches to Scene 2 after 30 seconds. Then Scene 2 to Scene 3 after 30 seconds. Finally, switch from Scene 3 back to Scene 1 after 30 seconds, and repeat.

Very simple, but I'm having trouble doing it with this new version of scene switcher. Do I need to use the Macros tab? If so, how?
 

Attachments

  • Scene Switcher.PNG
    Scene Switcher.PNG
    40.1 KB · Views: 26

Warmuptill

Active Member
But better for me, I think, and a lot of other things as well, would be to connect to a specific pre-existing event like my python script does, instead of just the entire server and leaving it at that. Would that also be possible?
The websocket condition only listens for "vendor" events and requests so no every single websocket event available via the obs-websocket API.
It also only sends out vendor requests and events specific to the advanced scene switcher.
(Sorry if I misunderstood your question)

I've been having no luck with getting Or Not statements to work. For example if I have it checking for if a file is not 0, or a second file is not, It will not work How I expect it to. It will perform the macro if the first condition is satisfied but not the second.
Enabling these visual indicators might help you figure out what is going wrong:

But I might also be able to help / propose a different solution if you describe in a bit more detail what you want to achieve exactly.

Just guessing below:
I would assume you want a certain set of actions to happen if either player1 or player2 have scored at least one point.
You could run into the situation with your current set of conditions, that, if either player has already scored and the other one now scores a point, the actions of the macro would not be performed, as you have enabled "Perform actions only on condition change". (Which might lead you to believe that the "or not" is not working)
 

AaronD

Active Member
The websocket condition only listens for "vendor" events and requests so no every single websocket event available via the obs-websocket API.
It also only sends out vendor requests and events specific to the advanced scene switcher.
(Sorry if I misunderstood your question)
Something seems a little bit off (surely it can't be THAT limited!), but it could just as easily be *my* misunderstanding. :-) Let's see:

It would appear that an external thing, like my python script, can register for any WebSocket event, and that there's already one for a scene change that includes the name of the new scene. That name must be extracted from the message object, but it's there.

Meanwhile, if I understand you correctly and put things together, Adv. SS only uses the API to access WebSocket messages, and doesn't actually do it directly. And the API filters out almost everything. The one thing that does get through, only has a single string, so that's all that the GUI provides for.

Thus, two instances of Adv. SS can talk to each other because they automatically use "vendor" events and requests, but because that's ALL that comes through the API, I can't have Adv. SS receive an already-existing scene change event from the other instance of OBS.

Is that more-or-less right?



If so, then:
  • I can imagine some compatibility problems with other apps that want or send something other than "vendor". It seems like the functionality is almost limited to *only* connecting to other instances of Adv. SS, unless the other end just happens to also use "vendor" type messages.
  • How much effort would it take to either:
    • Do the WebSockets directly, bypassing the API, so that Adv. SS appears as a completely separate program as far as that's concerned?
      • Yes, I know there used to be a standalone plugin entirely for WebSockets, and this would re-include at least the core of that plugin into this one. But since the original plugin has been integrated now, and presents a big regression in functionality as I need it (multiple simultaneous instances must use the same settings, so that I can't tell them apart)...
    • Add a ton of environmental variables to send to the receiving instance of Adv. SS. Things like CURRENT_SCENE, STREAMING_ACTIVE, TOKEN(n) from a regex in one of the conditions, who knows what someone might want to use if it's there, etc...
      • I would then have a Master macro like "If scene changed" "send WS event $CURRENT_SCENE", and a set of Slave macros like the screenshot a few posts back, that each run a different regex on that same event and switch to the appropriate scene.
Or if you know a better way to automate a second (Slave) instance of OBS on the same machine, without making it prohibitively expensive to add and remove things in the first (Master) instance (no changing settings to match the new set of scenes, though an external controller that auto-updates its list could be allowed), that can be good too.
 

AaronD

Active Member
I'm also thinking about moving the different audio mixes in the Master for each of my "types" of scene, out of the scenes and into the global settings so that the scenes themselves *only* have to include the visuals, and then automating the audio fade-ins and -outs using a similar bit of logic as what I'm presently trying to have in the Slave. If I do *that*, then the regex on the scene name (or whatever method I end up using) would have to be in the *Master* macros, and since the audio fade actions need constant values anyway, I'll be in a perfect position to send a constant-string WebSocket message to the Slave.

I'm not at the machine at the moment to see if I can have a regex on the local current scene name. If so, then I *might* be home free with what exists already. (if I can also get a WS message from one instance to another on the same machine, when they insist on using the same server settings) It would put even more behind-the-scenes logic in the Master, which conflicts with the idea of keeping the often-duplicated stuff simple, but if I get it right and it never changes, then maybe it's okay?



I would then have:

Master:
  • Conditions
    • If scene changed
    • And regex $CURRENT_SCENE ^Camera.*$
  • Actions (all simultaneous)
    • Fade Global Audio 1 to 100%
    • Fade Global Audio 2 to 0%
    • Send "Camera" to WS event
Slave:
  • Conditions
    • If WS event "Camera"
  • Actions
    • Switch scene "Camera"
with of course a separate copy of each for each type of scene: "Camera", "Feature", or "Voiceover" so far.
 

JoqniX

New Member
hi im having a weird bug or so~ where adv-ss v1.19.2 doesnt save properly~ especially for macros

i had made a setup where it turns on / off sources depending on if the application exists or not~
but apparently on every obs launch i have to go back and change it to make it work as it should~

here my issue was -
conditions of `More than ` .....
was supposed to be `Exactly`
so if i were to change it to `Exactly` and close out of adv-ss or export it and import it, it still doesnt save it~ at all~ dunno what is up with this!

this screenshot is from me just launching obs and opening up adv-ss~ ( as you can see its still saving as `more than `
1669466370914.png
 

Warmuptill

Active Member
Meanwhile, if I understand you correctly and put things together, Adv. SS only uses the API to access WebSocket messages, and doesn't actually do it directly. And the API filters out almost everything. The one thing that does get through, only has a single string, so that's all that the GUI provides for.

Thus, two instances of Adv. SS can talk to each other because they automatically use "vendor" events and requests, but because that's ALL that comes through the API, I can't have Adv. SS receive an already-existing scene change event from the other instance of OBS.

Is that more-or-less right?
Yes, correct.
The advanced scene switcher simply uses the already existing infrastructure the obs-websocket plugin provides with OBS 28 to facilitate communication to other instances of the advanced scene switcher.
It does not process other requests / events.

I can imagine some compatibility problems with other apps that want or send something other than "vendor". It seems like the functionality is almost limited to *only* connecting to other instances of Adv. SS, unless the other end just happens to also use "vendor" type messages.
External applications can use the regular obs-websocket API to communicate with the advanced scene switcher.
Here is an example:

Do the WebSockets directly, bypassing the API, so that Adv. SS appears as a completely separate program as far as that's concerned?
That would be quite a large undertaking, for which I do not really see the benefit.

Add a ton of environmental variables to send to the receiving instance of Adv. SS. Things like CURRENT_SCENE, STREAMING_ACTIVE, TOKEN(n) from a regex in one of the conditions, who knows what someone might want to use if it's there, etc...
That is indeed my intention with the variable support.
I will likely build it up slowly over time as people request features.

Or if you know a better way to automate a second (Slave) instance of OBS on the same machine, without making it prohibitively expensive to add and remove things in the first (Master) instance (no changing settings to match the new set of scenes, though an external controller that auto-updates its list could be allowed), that can be good too.
Maybe the old "Network" tab will work for you?
It basically allows to sync the current scene of multiple OBS instances with one being the master.
There is however the limitation that the scenes will have to have the same name.





hi im having a weird bug or so~ where adv-ss v1.19.2 doesnt save properly~ especially for macros

i had made a setup where it turns on / off sources depending on if the application exists or not~
but apparently on every obs launch i have to go back and change it to make it work as it should~

here my issue was -
conditions of `More than ` .....
was supposed to be `Exactly`
so if i were to change it to `Exactly` and close out of adv-ss or export it and import it, it still doesnt save it~ at all~ dunno what is up with this!

this screenshot is from me just launching obs and opening up adv-ss~ ( as you can see its still saving as `more than `
View attachment 89140

Thanks for reporting the problem!
That particular setting not saving properly is simply a bug.

A build with a fix will be available here in a few minutes:
You will need to be logged into GitHub to be able to download it - let me know if that should be an issue.
 

JoqniX

New Member
Thanks for reporting the problem!
That particular setting not saving properly is simply a bug.

A build with a fix will be available here in a few minutes:
You will need to be logged into GitHub to be able to download it - let me know if that should be an issue.
yesh it does work~ it is now saving ( just checked it by relaunching obs a couple of times) but on first launch after installing this build - it seems to have reseted my previous settings and changed it into "less than" for both of the macros~ other than that all good~
 

AaronD

Active Member
External applications can use the regular obs-websocket API to communicate with the advanced scene switcher.
Here is an example:
As long as the other app can always use the CallVendorRequest type, yes. But I was imagining one that was hard-coded for something else, and someone wanted to make a connection between it and Adv. SS. Then we have a problem of, "The data is there, and another app can connect to it. Why can't this one?" Which is pretty much the problem that I have already when looking at a different instance of OBS.

Maybe the old "Network" tab will work for you?
It basically allows to sync the current scene of multiple OBS instances with one being the master.
There is however the limitation that the scenes will have to have the same name.
Almost there, but I think the "same name" limitation will be a deal-killer for me. I need a partial name match, not a complete one, so that a bunch of Master scenes map to the same Slave scene, and I can add and remove Master scenes without changing the Slave at all.
 
Top