WarmUpTill / SceneSwitcher

An automation tool for OBS Studio
https://obsproject.com/forum/resources/automatic-scene-switching.395/
GNU General Public License v2.0
984 stars 78 forks source link

sequence match blocks starting record/stream #64

Closed psifertex closed 3 years ago

psifertex commented 4 years ago

I'm trying to enable automatic recording upon selection of a scene that also then automatically transfers to a difference scene.

Automatic recording works fine, but as soon as I add a sequence transition to transition after a delay or immediately upon selecting the "start recording" scene, the recording is not actually started anymore.

Is this expected behavior or a bug?

WarmUpTill commented 4 years ago

I would assume that this is a bug, unless I am misunderstanding something.

The following setup does not seem to reproduce the issue on my end:

Sequence: scene1 -> 3s -> scene2 scene2 -> 3s -> scene3 scene3 -> 3s -> scene1

Automatically start recording on scene2.

The recording is always started when entering scene2 using the sequence or when manually switching to it.

Does a setup like this cause the issue on your end?

There is a limitation that the automatic starting of the recording will only happen once for each scene change. https://github.com/WarmUpTill/SceneSwitcher/blob/16c4a2d5a96b126151ee33eeb0e4f0b9121b3c9d/src/general.cpp#L220-L221 The reason being so you can actually stop a recording and will not be spammed with errors if there is an invalid stream / recording configuration.

Is this what you are referring to?

psifertex commented 4 years ago

My desired behavior is similar to your setup above. Let me try with a fresh set of scenes to confirm and see if I can isolate why I'm not seeing the same behavior. I have very few rules in my setup. Is there a consolidated configuration file I can extract and post that might make it easier to see my settings?

psifertex commented 4 years ago

Ahh, just found the export. Here's my current settings if it helps:

{
    "active": true,
    "audioSwitches": [],
    "audioTabPos": 12,
    "autoStartEnable": true,
    "autoStartSceneName": "Start Recording",
    "autoStartType": 0,
    "autoStopEnable": true,
    "autoStopSceneName": "Ending Blank",
    "defaultTransitions": [],
    "disableHints": false,
    "exeTabPos": 4,
    "executableSwitches": [],
    "fileSwitches": [],
    "fileTabPos": 7,
    "generalTabPos": 0,
    "idleEnable": false,
    "idleSceneName": "",
    "idleTabPos": 10,
    "idleTime": 60,
    "idleTransitionName": "",
    "ignoreIdleWindows": [],
    "ignoreWindows": [],
    "interval": 300,
    "mediaSwitches": [
        {
            "restriction": 0,
            "scene": "Start Recording",
            "source": "IntroMovie",
            "state": 6,
            "time": 0,
            "transition": "Fade"
        },
        {
            "restriction": 0,
            "scene": "Ending Blank",
            "source": "OutroVideo",
            "state": 6,
            "time": 0,
            "transition": "Fade"
        }
    ],
    "mediaTabPos": 6,
    "non_matching_scene": "",
    "pauseScenes": [],
    "pauseTabPos": 2,
    "pauseWindows": [],
    "priority0": 0,
    "priority1": 1,
    "priority2": 2,
    "priority3": 3,
    "priority4": 4,
    "priority5": 5,
    "priority6": 6,
    "priority7": 7,
    "priority8": 8,
    "randomSwitches": [],
    "randomTabPos": 8,
    "readEnabled": false,
    "readPath": "",
    "regionTabPos": 5,
    "sceneRoundTrip": [
        {
            "delay": 0.0,
            "delayMultiplier": 1,
            "sceneRoundTripScene1": "Start Recording",
            "sceneRoundTripScene2": "FaceCam",
            "transition": "Fade"
        }
    ],
    "sceneTransitions": [],
    "screenRegion": [],
    "sequenceTabPos": 11,
    "startHotkey": [],
    "startup_behavior": 0,
    "stopHotkey": [],
    "switch_if_not_matching": 0,
    "switches": [],
    "tansitionOverrideOverride": false,
    "threadPriority": 3,
    "timeSwitches": [],
    "timeTabPos": 9,
    "titleTabPos": 3,
    "toggleHotkey": [],
    "transitionTabPos": 1,
    "verbose": false,
    "writeEnabled": false,
    "writePath": ""
}
psifertex commented 4 years ago

The flow is that the Intro scene has a media file that when completed auto-switches to Start Recording which triggers recording and immediately transitions to FaceCam. The transitions are happening but the recording isn't starting. As soon as I disable the sequence transition from Start Recording to FaceCam (or just temporarily trigger it on another unrelated scene) the recording happens but obviously i'm stuck on a black scene then.

WarmUpTill commented 4 years ago

I think I have now understood the problem:

As mentioned previously, there is a limitation that the automatic starting of the recording will only happen once for each scene change. The reason being so you can actually stop a recording and will not be spammed with errors if there is an invalid stream / recording configuration. https://github.com/WarmUpTill/SceneSwitcher/blob/16c4a2d5a96b126151ee33eeb0e4f0b9121b3c9d/src/general.cpp#L220-L221 This flag limiting the automatic starting of streaming and recording is reset on receiving the OBS_FRONTEND_EVENT_SCENE_CHANGED signal which is emitted when a transition of a scene change completes. https://github.com/WarmUpTill/SceneSwitcher/blob/4f6275619a1a3da157c302b31dcf58cbbb29b42e/src/advanced-scene-switcher.cpp#L546-L548

So you are on the Intro scene and the check for automatically starting recording / streaming finished and the flag is set to not try this again until OBS_FRONTEND_EVENT_SCENE_CHANGED resets this. You are now switching from scene Intro to scene Start Recording using a fade transition, after the corresponding media state is reached. To complete this transition a certain amount of time needs to pass before you are on scene Start Recording and OBS_FRONTEND_EVENT_SCENE_CHANGED is emitted. While this transition is still going on the scene switcher notices that you are on Start Recording and checks if it should start the recording, but notices the flag to skip this step is still set. One of the next checks is then the scene sequence one. For this a match is found for Start Recording for which you entered a delay of 0ms so the scene switcher immediately switches to the next scene FaceCam.

So now you ended up on FaceCam but the recording was not started.

Unfortunately I do not know of a good way around this problem, if you really need this exact configuration.

To work around it you could either increase the delay from Start Recording to FaceCam to be longer than the fade transition or similarly you could increase the check interval of the scene switcher to be longer than the fade transition will last.

Does this help?

psifertex commented 4 years ago

I can just use a cut transition, I don't actually need it to be a fade. Let me try that work-around.

WarmUpTill commented 3 years ago

I assume the work-around functioned as expected - if not please let me know. I will close this for now as I do not see any easy solution.