admshao / obs-transition-matrix

GNU General Public License v2.0
97 stars 13 forks source link

After the recording or broadcast, the first transition effect will not be triggered correctly. #3

Closed Danjuanlab closed 4 years ago

Danjuanlab commented 5 years ago

After the recording or live broadcast, the first transition effect will not be triggered correctly. The second and later transition can be triggered correctly. I have found the same question in the OBS Studio forum and hope to find the bug.

ochilan commented 4 years ago

Hello,

after looking into the code, I think that I see the error, but I don't know if my fix is the right way to go. When starting a recording, the following functions are called:

handle_obs_frontend_save_load -> save_matrix_data -> save_default_transition_override

The last function causes the default transitions (or rather the "any" overrides) to be applied to all scenes. However, the overriding transitions are not re-applied afterwards.

A possible fix could be to call "update_scenes_transition_override" at the end of "save_matrix_data". @admshao Do you think this would be a valid fix, or would you suggest another approach?

Best regards Ochi

admshao commented 4 years ago

@ochilan Perfect valid for me.

The issue here is that I ever tested it while never streaming/recording.

I missed that case from the handle_obs_frontend_save_load being called.

Great catch @ochilan .

It took me so long to be able to repro this...almost a year lol

Fixed on master

ochilan commented 4 years ago

I'm afraid to say that I now noticed that the change broke something else. Consider the following order of events:

Now check the transition matrix: Depending on which scene was active when closing OBS, one of the transitions between the scenes has also been applied to the "Any" row. And once this change has been done, it stays like that. After some time (depending on the active scene when closing OBS), more and more fields of the "Any" row may also be affected.

My guess for the reason behind this is as follows. When loading the matrix state, the plugin checks which transition each scene has (i.e. the regular per-scene transition override you can set in vanilla OBS). It will then apply any transition it finds to the corresponding field in the "Any" row.

Before the "fix", the plugin would reset the per-scene overrides to those of the "Any" row before saving took place. When loading the matrix the next time, it would then re-apply the per-scene overrides to the "Any" row.

After the "fix", the plugin restores the transition overrides for the active scene before OBS continues saving the per-scene overrides. However, we will now restore (part of?) this state to the "Any" row when OBS is launched the next time.

I'm not yet sure what would be the best way to fix this issue, but it's not the end of the story yet. Sorry :\

ochilan commented 4 years ago

After giving it some more thought, maybe the least invasive way to fix the problem at hand (first transition after starting recording/stream is wrong) would be to listen to the

OBS_FRONTEND_EVENT_RECORDING_STARTED OBS_FRONTEND_EVENT_STREAMING_STARTED

events and update the transitions there and not in save_matrix_data. It's not perfect since other things could also trigger the save callback so you never know when the transitions might be reset. In fact this also happens when stopping a recording.

Another solution might be to ignore the default per-scene overrides completely and simply save and load the "Any" row ourselves like the other rows. However, I guess there is a reason for having the "Any" column in the first place (to not interfere with the default per-scene transitions in case the plugin is not used at all in a scene collection?).

EDIT: Nope... the first idea is no good either since the "recording started" event is fired before the "handle save" callback. :(