Video is not displayed immediately when the source becomes visible

TheCatAndI

New Member
I wrote a script that hides an image and shows a video.

Lua:
local obs = obslua

local SourceVideo = obs.obs_get_source_by_name("Video")
local SourceImage = obs.obs_get_source_by_name("Image")

local Scene = obs.obs_scene_from_source(obs.obs_frontend_get_current_scene())

local SceneItemVideo = obs.obs_scene_sceneitem_from_source(Scene, Source)
local SceneItemImage = obs.obs_scene_sceneitem_from_source(Scene, Source2)

obs.obs_source_update(SourceVideo, nil)
obs.obs_sceneitem_set_visible(SceneItemVideo, true)
obs.obs_sceneitem_set_visible(SceneItemImage, false)

However, when the script is run, it turns out that the image is no longer visible, and the video does not appear immediately, but only after a few frames. How can this be fixed?
 
In the properties for an OBS Video Capture source, there is a checkbox "Deactivate when not showing." If you have that checked, it might take a few frames before there is an image to show. If your source is VLC or Media Source, there may be similar settings.
 
Top