How to properly transition a scene in Lua

superlou

New Member
I am working on a plugin to simplify the use of "down-stream key" scenes.

For this example, I have a basic scene called "Scene 1" containing my main video scene. I also have a second "Bug DSK" scene that has a small looping video in the lower right.

In the frontend GUI, I perform the following steps:

1) Scene 1 in program and preview. Scene 1 does not contain Bug DSK and it is not showing in program.
2) Add Bug DSK to the Scene 1 source list. Bug DSK now shows overlayed in the preview monitor, but is not in the program monitor (which is exactly what I want).
3) Execute a Fade transition. The bug fades into the program monitor. It is still shown on the preview monitor.
4) Delete the Bug DSK source from the Scene 1 source list. The bug disappears from the preview monitor, but continues showing in the program monitor.
5) Execute a Fade transition. The bug fades from the program monitor (which is also exactly what I want).

So, now I do this in Lua, starting with Scene 1 in preview and program, not containing the Bug DSK scene, as before:

...
obs.obs_scene_add(obs.obs_scene_from_source(scene1), dsk)
obs.obs_transition_start(fade, obs.OBS_TRANSITION_MODE_AUTO, 2000, current)​

This is awesome. It behaves the same as in steps 1, 2, and 3. However, now when I manually go to perform step 4 (delete the Bug DSK source), it immediately disappears from program, as well as preview. If I run the Lua script again at this point, the bug immediately appears in program; it doesn't transition in.

I noticed that if I run the script, and then execute a transition using the GUI buttons, behavior when performing 4 and 5 manually is as expected.

So, is there something like an obs_transition_end(...) or other call that is required? Is the behavior in steps 1 through 5 by design, or am I trying to make use of undefined behavior?
 

superlou

New Member
I'm starting to think I can't just find the fade transition using obs_frontend_get_transitions, then use obs_transition_start with that object. Do I need to create a new (maybe private?) transition source?
 

superlou

New Member
I think I might have figured it out: when in studio mode, the GUI creates duplicate scenes to transition to when you click a transition button: https://github.com/jp9000/obs-studio/blob/master/UI/window-basic-main-transitions.cpp#L299-L305.

If I do the following in Lua, steps 4 and 5 behave as expected.

obs.obs_scene_add(obs.obs_scene_from_source(current), dsk)
current_scene = obs.obs_scene_from_source(current)
scene = obs.obs_scene_duplicate(current_scene, nil, obs.OBS_SCENE_DUP_PRIVATE_REFS)
dest_source = obs.obs_scene_get_source(scene)

obs.obs_transition_start(fade, obs.OBS_TRANSITION_MODE_AUTO, 500, dest_source)

I think that gives me all the fundamental components I need to make DSKs that can fade in and out. I think there's a pathway to decoupling the DSK transition from the main scene transition by making a new "sub-transition" that is a source containing the DSK scene. This would let you create a swipe or stinger that applied just to the DSK, but I can live with just fades for now.
 
Top