Git Product home page Git Product logo

Comments (2)

Julian-O avatar Julian-O commented on May 27, 2024 1

There seems to be three parts to this question:

I can't always answer such questions. I have read the API documentation several times but it doesn't always make sense to me and I have had only moderate experience.

  • When I know what I want to do with the Streamlabs-OBS API, how do I do the equivalent in PySLOBS?

I may be able to help there.

  • How do I use Python?

I may refer you to Stack Overflow or similar for such questions.


To create a video source in a scene, you need to do three things:

  1. Find the scene.
  2. Create the source.
  3. Add the source to the scene.

Find The Scene

In your code, you call list_all_scenes(conn) from the example code. That will not find your scene. That will just print all the scene names to the screen.

If you look at the code for list_all_scenes() you will find it says:

  for scene in scenes:
         print(" - ", scene.name)

You probably need a function, perhaps called find_scene() that does something like:

 for scene in scenes:
       if scene.name == "The Scene I want":
            return scene

You can then call this function:

my_scene = await find_scene(conn)

Create the source

To create the source, you need to call create_source, but you need to pass parameters to it. Here is an example for a browser_source:

    source = await ss.create_source(
        name="Exercise Browser Source",
        type_="browser_source",
        settings={"url": "http://twitter.com/PuzzlingOldMan"},
        # Tested with is_temporary = True, and it wasn't found in search,
        # which presumably is correct.
        options=ISourceAddOptions(channel=None, is_temporary=False),
    )

You don't want browser_source. I don't know what settings you will require. The way I would work it out is to manually create the source, and then use some code like show_all_sources(conn) in the test directory to read all the options, types and settings, and pass all the important parameters to create_source.

Add the source to the scene.

With all the pieces in place, this should be easy.

 scene_node = await scene.add_source(source.source_id)

from pyslobs.

hiro-551010 avatar hiro-551010 commented on May 27, 2024

I wanted to add a source to the scene we're looking at, so here's what I did. Thank you.

async def create_sources(conn):
    active_scene = await active_scenes(conn)
    ss = SourcesService(conn)
    source = await ss.create_source(
        name = "cat",
        type_ = "ffmpeg_source",
        settings = {
            "is_local_file": True,
            "local_file": "D:\\twitchbot\media\cat.mp4"
            },
        options = ISourceAddOptions(channel=None, is_temporary=False)
    )
    source_node = await active_scene.add_source(source.source_id)

from pyslobs.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.