About C# WPF control of OBS Studio

kaiS

New Member
C# WPF control OBS Studio can control the functions of OBS Studio, such as creating scene sets and switching scenes, after being connected through OBS-WebSocket. Currently, it needs to be controlled through the interface in OBs-frontend-api.dll
OBS Studio creates scene sets, switches scenes, and so on. Obs-frontend -api.dll has been viewed through Developer Command Prompt for Vs 2022
obs_frontend_get_scene_collections = obs_frontend_get_scene_collections
obs_frontend_get_scene_names = obs_frontend_get_scene_names
obs_frontend_get_scenes = obs_frontend_get_scenes
These interfaces are included
[DllImport("E:\\obs-studio\\bin\\64bit\\obs-frontend-api.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern IntPtr obs_frontend_get_scene_collections();
private static extern void obs_frontend_set_current_scene_collection(string collection);

public static List<string> GetSceneCollectionsList()
{
var sceneCollections = new List<string>();
var ptr = obs_frontend_get_scene_collections();
if (ptr == IntPtr.Zero) return sceneCollections;

try
{
var currentPtr = ptr;
while (true)
{
var strPtr = Marshal.ReadIntPtr(currentPtr);
if (strPtr == IntPtr.Zero) break;
var str = Marshal.PtrToStringAnsi(strPtr);
sceneCollections.Add(str);
currentPtr += IntPtr.Size;
}
}
finally
{


}

return sceneCollections;
}
if (ptr == IntPtr.Zero) return sceneCollections; if (PTR == intptr.zero) return scenecollections; Will directly return sceneCollections;
[DllImport("E:\\obs-studio\\bin\\64bit\\obs-frontend-api.dll", CallingConvention = CallingConvention.Cdecl, CharSet = charset.ansi)] is the actual obs-studio installation directory address
Given that ptr == IntPtr.Zero currently exists a scene set, is there a code problem? Or does obs-frontend-api.dll not support such a call?
 

kaiS

New Member
Ask if the API may not be intended for external calls, or is only available under certain conditions. Have other developers successfully called the API from the outside?
 

kaiS

New Member
If the API does not support the call whether there are other methods to support c# can call the way to achieve the creation of the scene, access to the scene collection and other functions
 

R1CH

Forum Admin
Developer
The obs-frontend-api.dll exports are intended for use by plugins, calls must be made inside the OBS process - you cannot use it externally.
 

kaiS

New Member
The obs-frontend-api.dll exports are intended for use by plugins, calls must be made inside the OBS process - you cannot use it externally.
Thank you. Is it possible to control OBS through external calls through lua scripts or other apis?
 

kaiS

New Member
I need help. May I ask that OBS can be controlled by calling an API interface of OBS through C# instead of OBS-Websocket connection
 
Top