Search code examples
python-3.xobs

How to create source type image in python code?


I am trying to create the source type image from python script in obs. Want to know proper steps to create source in script. I already checked, no proper doc for python scripting available.

obs.obs_source_create('banner-image','xyz')
obs.obs_source_create('banner-image','xyz')

Logs

TypeError: obs_source_create() takes exactly 4 arguments (2 given)

I want to create source type image from scrip & add that source to my current scene


Solution

  • This may be a simple FFI implementation, so try:

    obs.obs_source_create('banner-image', 'xyz', None, None)
    

    Source: First hit on Google when searching for "obs_source_create":

    Excerpt:

    obs_source_t *obs_source_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
    

    Creates a source of the specified type with the specified settings.

    The “source” context is used for anything related to presenting or modifying video/audio. Use obs_source_release to release it.

    Parameters:

    • id – The source type string identifier
    • name – The desired name of the source. If this is not unique, it will be made to be unique
    • settings – The settings for the source, or NULL if none
    • hotkey_data – Saved hotkey data for the source, or NULL if none

    Returns:

    • A reference to the newly created source, or NULL if failed