Advanced Scene Switcher

Advanced Scene Switcher 1.28.1

AaronD

Active Member
Thanks Warmuptill for this ever evolving plug-in....

TLDR; How can I make a macro wait for an image slide show to finish playing (not looped) and then move on to the next action?

Looking for advice on how to achieve something or maybe it requires an enhancement you could build into the plug-in in future? I'll try and explain as best I can:

I have setup through a macro a sequence of showing + hiding sources in a scene, so it's essentially cycling through showind and hiding some sources in the scene, pseudocode of the macro a bit like this:
Show source 1 (Image)
Wait 10 seconds
Hide Source 1
Show Source 2 (Image Slide Show)
Wait 30 seconds
Hide Source 2
Show Source 3 (Media File)
Wait 10 seconds

One of the sources (Let's say Source 2 in the above example) is an image slide show and the playlist of the slide show is a folder. The folder currently has 3 files in it and the slide show is set to display each image for 10 seconds, so 10 seconds per image - 30 seconds in total which is why I've set the source to be visible for 30 seconds BUT (and this is where I'm stuck) if the image file count for the slideshow changes, if I want each image to be shown for 10 seconds then I will have to manually change how long the source 2 is shown for (i.e. 4 images = waiting 40 seconds before hiding it).

What I would like to be able to do is have the amount of time the image slide show is shown for automated based on the image count in the folder / slide show playlist OR have it so the macro waits for the image slide show to finish once it starts playing and only then move on (hiding source 2 + showing source 3).

So far I've tried to approach it in different ways but not been successful:
- Thought about using variables some how but I would some how need to get a variable set to the count of files in the image slide show folder, then multiply this number by 10 and have that variable set for the 'Wait X seconds' in the macro after showing the image slide show source
- Tried making a macro which watches the state of the image slide show to be ended(playlist) and would then use this to advance to the next source (hiding source 2 + showing source 3) rather than waiting 30 seconds but this ended up always showing source 3 continously
- Thought about running a program / script which outputs the file count but not sure how to get this into advanced scene switcher as a variable or value to be used in the macro

Open to any ways you think I can do this? I think with one of the following features I'd be able to do it:
- Ability in the 'Wait' action to wait for a source property to be met (value equals or not equal to), also with a optional timeout value to stop it waiting indefinitely as a fall back). Also with this, the conditions to be able to 'Wait' before moving on to the next condition
- Ability to run a program and get it's output
- Ability to set a variables value from a (text) file

Thanks!
Showing/hiding things on a single scene is generally not the recommended way to do things. Have a dedicated scene for each thing instead, so you have lots of simple scenes instead of a few complex ones. If you're layering things so that all are visible at the same time, then of course you need all of that to be in the same scene, but beyond that, use a different scene.

Also, the Wait action commits you to the entire sequence unless you can stop the macro. *Maybe* that's what you want, as a form of "tamper resistance", but most of the time, I think you want it to be easily escapable. To do that, you'll have a bunch of macros:
  • Macro A
    • Conditions
      • If Scene A for 10 seconds
    • Actions
      • Switch to Scene B
  • Macro B
    • Conditions
      • If Scene B for 10 seconds
    • Actions
      • Switch to Scene C
  • Macro C
    • Conditions
      • If Scene C for 10 seconds
    • Actions
      • Switch to Scene D
  • Etc.
Then if you want to escape, just switch manually to something else. The timer will reset because it's not on that scene anymore, and so the macro won't run.

The pattern should be obvious, so now the question becomes, "How to collapse it all into one macro that follows that pattern?" I'm thinking about a naming convention for the scenes, that defines the available ones to switch to, and a sequence number. So then the one macro might be:
  • Sequence Macro
    • Conditions
      • If Scene <prefix><number> for 10 seconds
    • Actions
      • number = number + 1
      • Switch to Scene <prefix><number>
Each image in the slideshow is also its own scene, not a self-contained show.

Now the sequence can be any length, simply by the number of scenes that follow that naming convention. The macro stays the same regardless. It does rely on well-behaved error handling, when the scene past the end doesn't exist, so you might want to test that before you use it in production.

And maybe you have a second, "starting" macro that sets the variable and switches to the scene that it corresponds to. Maybe something like this:
  • Starting Macro
    • Conditions
      • <something>
    • Actions
      • number = 0
      • Run actions of Sequence Macro
If you follow the program flow here, that will Switch to Scene <prefix>1 and continue through the sequence. And the naming convention only exists in one macro, and is therefore easier to modify if needed.

@Warmuptill Is that use of variables possible?
 

OnlyZips

New Member
I am running into an issue on a Mac Studio running latest version of OBS when attempting to start the plug in and conduct a sequence of scenes it changes my scene transition duration to 20,000 ms. Is there anyway to prevent this from happening ?
 

Attachments

  • Screen Shot 2023-07-28 at 3.58.35 PM (3).png
    Screen Shot 2023-07-28 at 3.58.35 PM (3).png
    356.1 KB · Views: 30

biosmatrix

New Member
Showing/hiding things on a single scene is generally not the recommended way to do things. Have a dedicated scene for each thing instead, so you have lots of simple scenes instead of a few complex ones. If you're layering things so that all are visible at the same time, then of course you need all of that to be in the same scene, but beyond that, use a different scene.

Also, the Wait action commits you to the entire sequence unless you can stop the macro. *Maybe* that's what you want, as a form of "tamper resistance", but most of the time, I think you want it to be easily escapable. To do that, you'll have a bunch of macros:
  • Macro A
    • Conditions
      • If Scene A for 10 seconds
    • Actions
      • Switch to Scene B
  • Macro B
    • Conditions
      • If Scene B for 10 seconds
    • Actions
      • Switch to Scene C
  • Macro C
    • Conditions
      • If Scene C for 10 seconds
    • Actions
      • Switch to Scene D
  • Etc.
Then if you want to escape, just switch manually to something else. The timer will reset because it's not on that scene anymore, and so the macro won't run.

The pattern should be obvious, so now the question becomes, "How to collapse it all into one macro that follows that pattern?" I'm thinking about a naming convention for the scenes, that defines the available ones to switch to, and a sequence number. So then the one macro might be:
  • Sequence Macro
    • Conditions
      • If Scene <prefix><number> for 10 seconds
    • Actions
      • number = number + 1
      • Switch to Scene <prefix><number>
Each image in the slideshow is also its own scene, not a self-contained show.

Now the sequence can be any length, simply by the number of scenes that follow that naming convention. The macro stays the same regardless. It does rely on well-behaved error handling, when the scene past the end doesn't exist, so you might want to test that before you use it in production.

And maybe you have a second, "starting" macro that sets the variable and switches to the scene that it corresponds to. Maybe something like this:
  • Starting Macro
    • Conditions
      • <something>
    • Actions
      • number = 0
      • Run actions of Sequence Macro
If you follow the program flow here, that will Switch to Scene <prefix>1 and continue through the sequence. And the naming convention only exists in one macro, and is therefore easier to modify if needed.

@Warmuptill Is that use of variables possible?
Hello,

Thanks for spending time to reply and for your input. I’m afraid what you have suggested isn’t going to achieve what is needed…

I’m aware of ideally using scenes within scenes to achieve certain things and I’m already using this where it fits, in fact the way I have it setup now is using a nested scene. I’ll explain further:

We have scenes for cameras in a studio, a scene for another incoming remote stream and another scene for when nothing is ‘live’ - let’s call these the main scenes.

We now want to show images, image slide show and a video as a batch of adverts - when the adverts are showing, it needs to always be shown on top of which ever scene is active - so I have a ‘root’ scene which is in the main scenes and always visible. Inside the root scene is a ‘child’ scene - inside this scene is all the sources for the adverts. I have a macro setup so when the child scene is made visible, it starts cycling through all the advert sources (as per my original post). So no matter what main scene is active, the root scene shows the child scene which does the adverts.

So there’s method to the madness here - I don’t want and can’t have the scene to change away from the main scene and come back to it, as there are other factors which can change which main scene is showing and could happen at any time - so the main scene (whichever one is live) must always be showing with the adverts on top of it but in the event the main scene changes to another main scene, the adverts must continue to show and not be interrupted.

Hope the above makes sense.

Regarding image slide show images being their own scene - not sure what you mean by this?

Thanks!
 

Warmuptill

Active Member
@Warmuptill Is that use of variables possible?
That is indeed possible.
Something like this should to the trick:

Capture.PNG


I am running into an issue on a Mac Studio running latest version of OBS when attempting to start the plug in and conduct a sequence of scenes it changes my scene transition duration to 20,000 ms. Is there anyway to prevent this from happening ?
What you have configured is likely not what you want as you specified the duration of the scene transition to take 60 seconds respectively.
I assume this is what you wanted to do:

Capture2.PNG


Hello,

Thanks for spending time to reply and for your input. I’m afraid what you have suggested isn’t going to achieve what is needed…

I’m aware of ideally using scenes within scenes to achieve certain things and I’m already using this where it fits, in fact the way I have it setup now is using a nested scene. I’ll explain further:

We have scenes for cameras in a studio, a scene for another incoming remote stream and another scene for when nothing is ‘live’ - let’s call these the main scenes.

We now want to show images, image slide show and a video as a batch of adverts - when the adverts are showing, it needs to always be shown on top of which ever scene is active - so I have a ‘root’ scene which is in the main scenes and always visible. Inside the root scene is a ‘child’ scene - inside this scene is all the sources for the adverts. I have a macro setup so when the child scene is made visible, it starts cycling through all the advert sources (as per my original post). So no matter what main scene is active, the root scene shows the child scene which does the adverts.

So there’s method to the madness here - I don’t want and can’t have the scene to change away from the main scene and come back to it, as there are other factors which can change which main scene is showing and could happen at any time - so the main scene (whichever one is live) must always be showing with the adverts on top of it but in the event the main scene changes to another main scene, the adverts must continue to show and not be interrupted.

Hope the above makes sense.

Regarding image slide show images being their own scene - not sure what you mean by this?

Thanks!

Unfortunately I can't really think of a good solution at the moment, as there is no signal for the slide show being "done" as far as I am aware.
While the image slide show source is a considered a media source but will always remain in state "playing" unless its visibility is changed, so that is also not of use in your particular case.

I will try to look at the code for the silde show and see if I can come up with something.
 

biosmatrix

New Member
Unfortunately I can't really think of a good solution at the moment, as there is no signal for the slide show being "done" as far as I am aware.
While the image slide show source is a considered a media source but will always remain in state "playing" unless its visibility is changed, so that is also not of use in your particular case.

I will try to look at the code for the silde show and see if I can come up with something.
Thanks! If it’s not possible to know when the slideshow has finished, any method of getting a file count from a folder and then setting the wait time in the macro based on this would suffice. I.e get file count (4) then wait time = 4 x 10 (40 seconds).

Or any other way you think of
 

Warmuptill

Active Member
Thanks! If it’s not possible to know when the slideshow has finished, any method of getting a file count from a folder and then setting the wait time in the macro based on this would suffice. I.e get file count (4) then wait time = 4 x 10 (40 seconds).

Or any other way you think of
A build with the new condition type "Slide Show" will be available here in a few minutes:
It allows you to check ...
  • if the slide changed
  • the current slide index
  • the current slide path
So something like this might achieve what you are trying to do:

Capture.PNG
 

Destroy666

Member
Just to make sure I'm not missing anything, the best way to achieve scene toggle on ZoomIt LiveZoom toggle would be to:
- check if the process is running (unfortunately no separate process for magnifier as far as I see, just the app in general, correct me if I'm wrong)
- check if ZoomIt hotkey is pressed
- in one macro check if scene is not `X` with display capture and switch to `X` if so, in another check if scene is `X` and switch to previous scene if so
Right? It works, wondering if there's something simplier - maybe I'm missing a usable different process, although I checked with Process Monitor.

How to delete a variable BTW? I added PreviousSceneName because I didn't see `Previous scene` option at the top of `Switch scene` action, but it's unnecessary and clutters the list now.
 
Last edited:

biosmatrix

New Member
A build with the new condition type "Slide Show" will be available here in a few minutes:
It allows you to check ...
  • if the slide changed
  • the current slide index
  • the current slide path
So something like this might achieve what you are trying to do:

View attachment 96259
Amazing…. Haven’t tested this yet but if I’m understanding this correctly, I can check whether the slide hasn’t changed in X seconds therefore it has ‘finished’ right?

Massive thanks for doing this so quickly!
 

Warmuptill

Active Member
Just to make sure I'm not missing anything, the best way to achieve scene toggle on ZoomIt LiveZoom toggle would be to:
- check if the process is running (unfortunately no separate process for magnifier as far as I see, just the app in general, correct me if I'm wrong)
- check if ZoomIt hotkey is pressed
- in one macro check if scene is not `X` with display capture and switch to `X` if so, in another check if scene is `X` and switch to previous scene if so
Right? It works, wondering if there's something simplier - maybe I'm missing a usable different process, although I checked with Process Monitor.
Unfortunately I am not familiar with the tool, but I assume that your approach should be valid.

How to delete a variable BTW? I added PreviousSceneName because I didn't see `Previous scene` option at the top of `Switch scene` action, but it's unnecessary and clutters the list now
Just create a temporary macro action / condition of type "Variable" and delete it from there.
Once you cleaned up the unnecessary variable remove the temporary action / condition.

Amazing…. Haven’t tested this yet but if I’m understanding this correctly, I can check whether the slide hasn’t changed in X seconds therefore it has ‘finished’ right?

Massive thanks for doing this so quickly!
Correct! :)
 

Destroy666

Member
Just create a temporary macro action / condition of type "Variable" and delete it from there.
Once you cleaned up the unnecessary variable remove the temporary action / condition.

Ah, I see it's under the blue cog icon, I expected this but I missed that part, thanks.
 

Destroy666

Member
How does Run action parsing work exactly? If I wanted to use:
Code:
cmd /c start "" "D:\Temporary\Data\Media\Videos\Recorded\OBS Studio"
How would I define that? The quotes in arguments seem to be escaped if I just add everything after `cmd` in 1 argument, which results in an error of invalid location. And if I was to enter everthing separately then not sure how `""` should be represented.

Luckily, I noticed that you can simply paste:
Code:
D:\Temporary\Data\Media\Videos\Recorded\OBS Studio
into Run textbox and that works I think the same way as if I used `start`, but not sure if that's intended or if it may get broken at one point, as an executable file looks to be wanted there.

I also saw the plugin uses this: https://www.qt.io/blog/2017/08/25/a-new-qprocessstartdetached to execute the cmd but I couldn't really find any detailed info about quoting in it and I'm not too familiar with C++ or Qt.
 
Last edited:

Warmuptill

Active Member
How does Run action parsing work exactly? If I wanted to use:
Code:
cmd /c start "" "D:\Temporary\Data\Media\Videos\Recorded\OBS Studio"
How would I define that? The quotes in arguments seem to be escaped if I just add everything after `cmd` in 1 argument, which results in an error of invalid location. And if I was to enter everthing separately then not sure how `""` should be represented.

Luckily, I noticed that you can simply paste:
Code:
D:\Temporary\Data\Media\Videos\Recorded\OBS Studio
into Run textbox and that works I think the same way as if I used `start`, but not sure if that's intended or if it may get broken at one point, as an executable file looks to be wanted there.

I also saw the plugin uses this: https://www.qt.io/blog/2017/08/25/a-new-qprocessstartdetached to execute the cmd but I couldn't really find any detailed info about quoting in it and I'm not too familiar with C++ or Qt.
To add arguments click the "Show advanced settings" button of the run action.
This should do what you are looking to do:

Run.PNG
 

CodeYan

Member
A build with the requested functionality (and a bit more) is available here:

View attachment 96105
Wasn't quite sure how to best enable the user to select the different options so I resorted to yet another dialog.
If someone has better suggestions I am all ears :D

Couldn't to much testing yet so certainly make sure to back up your settings before trying this.

(Sorry that I took forever to get around to this topic)
Thanks, will test that out soon.

May I request that you add my source https://github.com/CodeYan01/media-playlist-source/ (source id is "media_playlist_source_codeyan", i put my name there because Media Playlist Source is generic) as a Media/Playlist source, along with VLC Video Source. Currently it doesn't show up under Media Source (as expected). Or, much better, have some config or something that lets plugin developers/users add source types for the source-specific actions?
 

Bairespm

Member
Hello @Warmuptill , I am currently testing on another pc with adv ss, I create a couple of macros and if they work perfectly I recreate them on the production pc. In order not to do this process that can cause errors, I would like to be able to select and export them from my test pc and import it on my production pc, without deleting or replacing what I already have created. Under this concept,
Can you create selective export / import?

thanks for your time
 

biosmatrix

New Member
Correct! :)

I can confirm this works! But only if set to 'Within the last':

1690811355836.png


Thanks again :)

Hello @Warmuptill , I am currently testing on another pc with adv ss, I create a couple of macros and if they work perfectly I recreate them on the production pc. In order not to do this process that can cause errors, I would like to be able to select and export them from my test pc and import it on my production pc, without deleting or replacing what I already have created. Under this concept,
Can you create selective export / import?

thanks for your time

Coincidently, this feature would of saved me a lot of time today! +1 from me on this.

Also, is it possible to have some buttons to move macro events/actions to the Top + Bottom? I would in visage it like this:

1690811687434.png


Thanks!
 

AaronD

Active Member
Hello @Warmuptill , I am currently testing on another pc with adv ss, I create a couple of macros and if they work perfectly I recreate them on the production pc. In order not to do this process that can cause errors, I would like to be able to select and export them from my test pc and import it on my production pc, without deleting or replacing what I already have created. Under this concept,
Can you create selective export / import?

thanks for your time
I wonder if a human-readable export file would be the easiest way to do this? Just export everything, pare down the file by hand, and import to the other one. Or maybe call it "Merge" for this functionality:
  • A macro name that exists in both the present config and the file to merge, is overwritten from the file.
  • A macro name that exists only in the file, is added from the file.
  • A macro name that exists only in the present config, remains unchanged.

A human-readable file might also be interesting for those who want to automate changing macros, because it would make it easy to create that automation (write to a file, then merge that file), but remember what I said about self-modifying code:
...it does remind me of "self-modifying software", which is usually a massive red flag in professional work. It's not to the point yet, of running automatically-generated code that was never in the original at all, which is where the most of the red flags come from (how do you debug THAT?!), but it's enough to bring the idea to mind.

This is definitely a programming language now, so I think it would really help to look at the software industry's best practices in how to manage software in general, and apply the same concepts here.
 

Bairespm

Member
I wonder if a human-readable export file would be the easiest way to do this? Just export everything, pare down the file by hand, and import to the other one. Or maybe call it "Merge" for this functionality:
  • A macro name that exists in both the present config and the file to merge, is overwritten from the file.
  • A macro name that exists only in the file, is added from the file.
  • A macro name that exists only in the present config, remains unchanged.

A human-readable file might also be interesting for those who want to automate changing macros, because it would make it easy to create that automation (write to a file, then merge that file), but remember what I said about self-modifying code:
I think making it readable for humans, to manually choose and import from there... would be the same or more work than creating them again. on the other hand make it readable for humans and then import it without deleting what was created. would be creating half the process. you export it one way and import it another doesn't seem productive to me.

I don't understand what you mention about automation. I'm just talking about selective export and import. by the following. on another pc I do tests and in the tests when I get it to work. I realize that I have about 10 macros... then when I get home I want to implement them in the production adv ss and therein lies the big problem... I have to remember what I did or take note, or at best the cases have screenshots of the macros to copy them manually. many times the time used is a lot, and not to mention if in the creation process you use test references. which you could really replace fast if you could just import and replace.
 

AaronD

Active Member
I think making it readable for humans, to manually choose and import from there... would be the same or more work than creating them again. on the other hand make it readable for humans and then import it without deleting what was created. would be creating half the process. you export it one way and import it another doesn't seem productive to me.
Your initial concern, as I understood it, was manual copying errors. The manually pared-down file may or may not reduce work - select a big chunk, delete, save - but for the data that gets through, it does allow that part to be handled entirely by machine, thus eliminating the manual copying error.

I don't understand what you mention about automation. I'm just talking about selective export and import.
I'm thinking beyond the box. What *else* could "___" functionality be used for?
 

Warmuptill

Active Member
Hello @Warmuptill , I am currently testing on another pc with adv ss, I create a couple of macros and if they work perfectly I recreate them on the production pc. In order not to do this process that can cause errors, I would like to be able to select and export them from my test pc and import it on my production pc, without deleting or replacing what I already have created. Under this concept,
Can you create selective export / import?

thanks for your time
A build with this functionality will be available here in a few minutes:

Here is the general work flow:
  1. Mark the macros you want to export and right click in the macro list to select the "Export" functionality.
    Export1.png
  2. Copy the contents of the dialog that pops up:
    Export2.png
  3. In the scene switcher instance / scene collection you want to import the macros in right click and select "Import".
    Import1.PNG
  4. Now paste the content you copied earlier in the dialog and click OK:
    Import2.PNG

  5. The macros are now added to your macro list.
    In case a name conflict with an already existing macro comes up you will e asked if you want to rename the new macro or skip its import.
As usual with test releases - please make sure to back up your settings beforehand before trying them.
And please let me know if you run into any issues! :)

(Pinging @biosmatrix as you were interested in this functionality also.)
 
Last edited:
Top