def toggle_source(self, scene, source): state = self.ws.call( requests.GetSceneItemProperties(item=source, scene_name=scene)).getVisible() print(state) self.ws.call( requests.SetSceneItemRender(source=source, render=(not state)))
def adjust_image_position(self, target_x, target_y): image_info = self.ws.call(requests.GetSceneItemProperties('Aver')) height = image_info.getHeight() width = image_info.getWidth() source_height = image_info.getSourceheight() source_width = image_info.getSourcewidth() return target_x * width / source_width, target_y * height / source_height
async def slide_in_from_right(source: str, scene: str, step: int, height: int): """Slides a OBS Source in from the right side of the display Args: source (str): Source Name scene (str): Scene Name step (int): How many steps per iteration to move in height (int): Height from the top down, -1 will set it at the bottom. """ # Grab screen output values screen_properties = obs_client.call(requests.GetVideoInfo()).datain # Values of the source item_properties = obs_client.call(requests.GetSceneItemProperties(source, scene_name=scene)).datain # Set Starting position to bottom if -1 if height == -1: height = int(screen_properties["baseHeight"] - item_properties["height"]) - 10 # Send the height, and set off right side of screen obs_client.call( requests.SetSceneItemPosition( source, height, screen_properties["baseWidth"] + 1, ) ) # Save how far in to slide slide_in_to_x = int(screen_properties["baseWidth"] - item_properties["width"]) # Turn on the scene obs_client.call(requests.SetSceneItemRender(True, source, scene_name=scene)) # Slide In r_from = int(screen_properties["baseWidth"]) for x in range(r_from, slide_in_to_x, step * -1): obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene)) # Move to width of item obs_client.call( requests.SetSceneItemPosition( source, height, slide_in_to_x, ) ) # Hold the position for a beat await asyncio.sleep(2) # Slide back out for x in range( slide_in_to_x, int(screen_properties["baseWidth"]) + 2, step * 2, ): obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene))
def main(): ws = obsws(host, port, password) ws.connect() ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) s1 = PROPERTIES(properties.datain) w = WINDOW_EASER(1280, 720) w.setWindow("f1") w.setWindow("f2") w.setKeyFrame("f1", 10 * 2, [0, 0, 1, 1]) w.setKeyFrame("f2", 10 * 2, [1, 0, 1, 1]) w.setKeyFrame("f1", 20 * 2, [0.1, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 20 * 2, [0.9, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 30 * 2, [0.1, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 30 * 2, [0.9, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 40 * 2, [0.5, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 40 * 2, [0.5, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 50 * 2, [0.5, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 50 * 2, [0.5, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 80 * 2, [0, 0, 1, 1]) w.setKeyFrame("f2", 80 * 2, [1, 0, 1, 1]) w.setupKeyFrame() while 1: for i in range(80 * 2): #print "=====================",i ret = w.update() #frame = w.draw() for source in sources: scale = s1.getScale(ret[source["name"]][3]) if "f2" == source["name"]: data = requests.SetSceneItemTransform( source["name"], -scale, scale, 0).data() else: data = requests.SetSceneItemTransform( source["name"], scale, scale, 0).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.01) data = requests.SetSceneItemPosition( source["name"], ret[source["name"]][0], ret[source["name"]][1]).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.01) #cv2.imshow("window",frame) #cv2.waitKey(1) w.initKeyFrame() ws.disconnect()
def active_media_source(self, live_scene_name="IRL Input"): # This assumes that the only visible media source is active. logging.debug(f"OBS property: active_media_source.") srcs = self.get_media_sources() for s in srcs: k = s["name"] if self.ws_call(requests.GetSceneItemProperties( k, live_scene_name)).getVisible(): return k
def main(): ws = obsws(host, port, password) ws.connect() PNFactoryX = perlin.PerlinNoiseFactory(1) PNFactoryY = perlin.PerlinNoiseFactory(1) ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) s1 = PROPERTIES(properties.datain) w = WINDOW_EASER(1280, 720) w.setWindow("f1") w.setKeyFrame("f1", 10 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 20 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 40 * 2, [-0.2, -0.2, 1.4, 1.4]) w.setKeyFrame("f1", 50 * 2, [-0.2, -0.2, 1.4, 1.4]) w.setKeyFrame("f1", 70 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 80 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setupKeyFrame() while 1: for i in range(80 * 2): #print "=====================",i ret = w.update() #frame = w.draw() for source in sources: scale = s1.getScale(ret["f1"][3]) data = requests.SetSceneItemTransform(source["name"], scale, scale, 0).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( source["name"], ret["f1"][0] + PNFactoryX(i / 30.0) * 20 - 20, ret["f1"][1] + PNFactoryY(i / 30.0) * 20 - 20).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.02) #cv2.imshow("window",frame) #cv2.waitKey(1) w.initKeyFrame() ws.disconnect()
def HiloFuenteArchivo(self): DataEscenaActual = self.OBS.call(requests.GetCurrentScene()).datain Refrescar = False for Fuente in DataEscenaActual["sources"]: NombreFuente = Fuente["name"] EstadoFuente = ObtenerValor("data/obs_fuente.json", NombreFuente, Depurar=False) EstadoFuenteActual = self.OBS.call(requests.GetSceneItemProperties(NombreFuente)).datain if "visible" in EstadoFuenteActual: EstadoFuenteActual = EstadoFuenteActual["visible"] if EstadoFuente is not None: if EstadoFuente != EstadoFuenteActual: self.CambiarFuente(Fuente=NombreFuente) Refrescar = True else: SalvarValor("data/obs_fuente.json", NombreFuente, EstadoFuenteActual) Refrescar = True self.SalvarFiltroFuente(NombreFuente) if Refrescar: self.actualizarDeck()
#original document # https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md host = "localhost" port = 4444 password = "******" ws = obsws(host, port, password) ws.connect() ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) t0 = time.time() for i in range(50): for source in sources: properties = ws.call( requests.SetSceneItemPosition(source["name"], np.sin(i / 20.0) * 100 + 100, 0)) t1 = time.time() #command no wait mode for i in range(200): for source in sources: #properties = ws.send(requests.SetSceneItemPosition(source["name"],0,np.sin(i/20.0)*100+100).data()) data = requests.SetSceneItemPosition(source["name"], 0,
def join(t): if not t.isAlive(): t.join() ws = obsws(host, port, password) ws.connect() incremental_x = 20 incremental_y = 20 incremental_z = 0.05 inc_rotation = 2 ###get value from the source item_state = ws.call( requests.GetSceneItemProperties(scene_name=scene, item=source_name)) filter_state = ws.call(requests.GetSourceFilters(sourceName=source_name)) filter_list = filter_state.datain #print filter_list, "filter_list" filter_type = filter_list[u'filters'] if filter_type: #print filter_type,"filter_type" filter_name = filter_type[0] #print filter_name, "filter_name" filter_name = filter_name[u'name'] #print filter_name, "filter_name" filter_visibility = filter_type[0] #print filter_visibility, "filter_visibility" filter_visibility = filter_visibility[u'enabled'] #print filter_visibility, "filter_visibility" filteronsource = True