Comments (2)
There seems to be three parts to this question:
- How do I do this using the Streamlabs-OBS API?
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:
- Find the scene.
- Create the source.
- 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.
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)
- tests and examples not included in PyPI package HOT 3
- Can I control someone else's OBS? HOT 1
- Waiting for luamacros script... HOT 1
- StreamLabs sends message without id or result field HOT 3
- StreamLabs OBS changed name to StreamLabs Desktop HOT 1
- StreamLabs Desktop uses undocumented NEWS NotificationSubtype HOT 1
- Use of id_ inconsistent. HOT 1
- Should be able to close a SlobsConnection without an async loop.
- ERROR:slobsapi.SlobsConnection:_receive_and_dispatch failing. HOT 4
- WARNING:slobsapi._SlobsWebSocket:Websocket failure: (Connection to remote host was lost.). Shutting down. HOT 1
- Python 3.9 required for Typing HOT 5
- There was something wrong with the set_scale and set_settings methods of the SceneItem class defined in pyslobs/slobs/scenenode.py. HOT 2
- Is it possible to change the visibility of sources? HOT 2
- SceneNode.set_visibility does not update cached visibility.
- Sceneitem_factory wrong return HOT 2
- AuthenticationFailure HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyslobs.