def __init__(self, host="localhost", port=4444, password=""): if password != "": self.ws = obsws(host, port, password) else: self.ws = obsws(host, port) self.ws.register(self.on_event) self.ws.register(self.on_vol, events.SourceVolumeChanged) #self.ws.register(self.on_switch, events.SwitchScenes) QApplication.processEvents() self.get_inputs() self.get_outputs() logging.debug("Setup OBS")
def OBS_StartStreaming(key,ingestion): """Handles GET requests""" falcon_logger.info("OBS_StartStreaming") falcon_logger.info("Key: %s Ingestion: %s" % (key,ingestion)) OBS_SetCamUrl(config.OBS.CAM_URL) ws = obsws(host, port, password) try: ws.connect() except: return 1,"Error de Conexion - ¿OBS Parado? - StartStreaming)" falcon_logger.info("Inicio Streaming") stream_settings = { "server":ingestion, "key":key, "use_auth":False } stream = { "settings":stream_settings, "type":"rtmp_custom" } rc=ws.call(requests.StartStreaming(stream)) falcon_logger.info(rc) ws.disconnect() return 0,"Ok"
def __init__(self, bot): self.bot: Bot = bot self.logger: logging.Logger = logging.getLogger("arachnobot.obs") self.vr: bool = False self.pretzel = None self.mplayer = None self.htmlfile = r'e:\__Stream\web\example.html' self.session = requests.Session() self.obsws_shutdown_timer: typing.Optional[Timer] = None self.ws: typing.Optional[obsws] = None try: # noinspection PyStatementEffect # noinspection PyUnresolvedReferences obsws_address # noinspection PyStatementEffect # noinspection PyUnresolvedReferences obsws_port # noinspection PyStatementEffect # noinspection PyUnresolvedReferences obsws_password except NameError: self.ws = None else: # noinspection PyUnresolvedReferences self.ws = obsws(obsws_address, int(obsws_port), obsws_password) self.ws.connect() self.aud_sources = self.ws.call(obsws_requests.GetSpecialSources())
async def obs_connect_command(ctx): if not ctx.author.is_mod: return if not dat.obsConnected: dat.ws = obsws(OBSHost, OBSPort, OBSPass) # change as your OBS setting dat.ws.connect() dat.obsConnected = True
def MsgToStream(message): global last_stream_message host = "172.24.1.99" port = 4444 password = "******" if message == 'start': name = 'Flight' last_stream_message = 0 if message == 'stop': name = 'Ambient+Results' last_stream_message = 2 if message == 'Ambient2': name = 'Ambient2' last_stream_message = 3 if message == 'Ambient2+Flight': name = 'Ambient2+Flight' last_stream_message = 1 if message == 'Ambient': name = 'Ambient' last_stream_message = 4 print(name) try: ws = obsws(host, port) ws.connect() time.sleep(1) ws.call(requests.SetCurrentScene(name)) time.sleep(1) ws.disconnect() except: pass
def __init__(self, bot=None): self.bot: TwitchChatBot = bot self.config_path = Path(__file__).parent / "config.json" with self.config_path.open() as f: self.config = SceneSwitcherConfig.from_json(f.read()) self.ws: obsws = obsws() self.last_set_scene = ""
def __init__(self, host, port, passwd): try: self.ws = obsws(host, port, passwd) self.ws.connect() print('Connected!') except Exception as e: print(e, file=stderr)
def StartAll(): global ws ws = obsws(obsIP, obsPORT, obsPWD) ws.register(on_event) ws.register(on_switch, events.SwitchScenes) ws.connect()
def __init__(self): self.ws = obsws(host, port, password) self.ws.connect() self.data = None self.scenes = None self.messageid = 0 self.controlCount = {} return
def connect(self): try: self.ws = obsws(self.config.host, self.config.port, self.config.password) self.ws.connect() except ConnectionFailure as e: logger.error("Error trying to connect to obs") pass
def __init__(self, server_ip, server_port, server_password, bypassexit=False): try: self.ws = obsws(server_ip, server_port, server_password) self.ws.connect() except Exception as e: PrintWithTime(f"Connection to OBS Websocket is impossible. Error: {e}") else: PrintWithTime("Connected to Websocket")
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 connect(self): try: self.ws = obsws(self.settings["host"], self.settings["port"], self.settings["password"]) self.ws.connect() self.connected = True self.established_connection_obs_once = True except ConnectionFailure: pass
def myOBScall(theRequest): host = "localhost" port = 4444 password = "******" ws = obsws(host, port, password) ws.connect() ws.call(theRequest) ws.disconnect() return ws
def Conectar(self, opciones): """Se conecta a OBS Websocket y inicializa los eventos.""" if "servidor" in opciones: self.host = opciones["servidor"] if "puerto" in opciones: self.port = opciones["puerto"] if "contrasenna" in opciones: self.password = opciones["contrasenna"] if self.Conectado: logger.info("OBS Ya Conectado") self.Notificar("OBS-Ya-Conectado") return try: if self.password is None: self.OBS = obsws(self.host, self.port) else: self.OBS = obsws(self.host, self.port, self.password) self.OBS.connect() self.Conectado = True logger.info(f"OBS[Conectado] {self.host}") self.Notificar("OBS-Conectado") except Exception as error: logger.warning(f"OBS[Error] {error}") self.LimpiarTemporales() self.Conectado = False SalvarValor("data/obs.json", "obs_conectar", False) self.Notificar("OBS-No-Encontrado") return self.SalvarEstadoActual() # self.OBS.call(requests.SetHeartbeat(True)) self.AgregarEvento(self.EventoEscena, events.SwitchScenes) self.AgregarEvento(self.EventoGrabando, events.RecordingStarted) self.AgregarEvento(self.EventoGrabando, events.RecordingStopping) self.AgregarEvento(self.EventoEnVivo, events.StreamStarted) self.AgregarEvento(self.EventoEnVivo, events.StreamStopping) self.AgregarEvento(self.EventoVisibilidadIten, events.SceneItemVisibilityChanged) self.AgregarEvento(self.EventoVisibilidadFiltro, events.SourceFilterVisibilityChanged) self.AgregarEvento(self.EventoSalir, events.Exiting) # self.AgregarEvento(self.EventoPulsoCorazon, events.Heartbeat) self.actualizarDeck()
def get_obs_client(): obs_client = obsws(secrets.obs_ip, secrets.obs_ws_port, secrets.obs_secret) while True: try: obs_client.connect() return obs_client except ConnectionFailure: print("OBS Connection Failure... sleeping 5 seconds.") sleep(5)
def __init__(self, ip_address="localhost", ip_port="4444", ip_secret="", already_open=False): """Create instance of OBS control""" self.ip = ip_address self.port = ip_port self.secret = ip_secret self.open = already_open self.client = obswebsocket.obsws(self.ip, self.port, self.secret)
def OBS_Escena(Escena): falcon_logger.info("Cambiando a escena: %s" % Escena) ws = obsws(host, port, password) try: ws.connect() except: return 1,"Error de Conexion - ¿OBS Parado?)" ws.call(requests.SetCurrentScene(Escena)) ws.disconnect() return 0,"Ok"
def OBS_SetSyncOffset(): falcon_logger.info("Configurando Sync Offset de %s en %s nanonesgundos" % (config.OBS.AUDIO_SOURCE,config.OBS.AUDIO_SYNC)) ws = obsws(host, port, password) try: ws.connect() except: return 1,"Error de Conexion - ¿OBS Parado?)" ws.call(requests.SetSyncOffset(source=config.OBS.AUDIO_SOURCE,offset=config.OBS.AUDIO_SYNC)) falcon_logger.info("Sync Offset configurado..") ws.disconnect()
def Conectar(self): try: print(f"Intentando Conectar con {self.host}") self.ConeccionOBS = obsws(self.host, self.port) # self.ConeccionOBS.register(on_event) # self.ConeccionOBS.register(on_switch, events.SwitchScenes) self.ConeccionOBS.connect() self.OBSConectado = True except: print("No se pudo conectar a OBS") self.OBSConectado = False
def socket_init(self): """ Init the socket. Raise ConnectionError if failed. :return: """ try: self.socket = obsws(self.IP, self.PORT, None if self.PASS == "" else self.PASS) self.socket.connect() except: self.socket = None raise ConnectionError
def ws_connect(self): logging.debug("OBS Command: Attempting websocket connection.") ws_host = self.config["websocket_host"] ws_port = self.config["websocket_port"] ws_secret = self.config["websocket_secret"] ws = obsws(ws_host, ws_port, ws_secret) logging.debug( f"OBS command: connect. host: {ws_host}, port: {ws_port}, secret: {ws_secret}." ) ws.connect() logging.debug(f"OBS Command: Websocket successful: {ws}") return ws
def main(): global config global leds global scenes, cv args = parser.parse_args() configfile = args.c with open(configfile, "r") as file: text = file.read() config = Config.from_json(text) # pylint: disable=no-member # Initialize LEDs try: gpiozero.LED() except gpiozero.exc.BadPinFactory: # Platform does not support real LEDs => use mock instead gpiozero.Device.pin_factory = gpiozero.pins.mock.MockFactory() except gpiozero.exc.GPIOPinMissing: # this is normal as we haven't given any pin number. # But we seem to be able to open a GPIO port :-) pass leds = LedInterface(config.tallies) # Connect to OBS client = obswebsocket.obsws(host=config.obs.host, port=config.obs.port, password=config.obs.password) client.register(on_scene_change, events.SwitchScenes) for event in [ events.ScenesChanged, events.SourceCreated, events.SourceDestroyed, events.SourceRenamed, events.SceneItemAdded, events.SceneItemRemoved, events.SceneItemVisibilityChanged, ]: client.register(trigger_scenelist_update, event) client.register(sys.exit, events.Exiting) client.connect() __update_scenes_and_leds(client) try: while True: with cv: cv.wait(timeout=5) # ... until scenelist update was triggered __update_scenes_and_leds(client) except KeyboardInterrupt: pass
def _connect(self): """Initiates connection with OBS Websockets, and will raise an exception if it fails to connect for any reason whatsoever """ self.log.info("Trying to connect to OBS Websockets...") try: self.client = obswebsocket.obsws(self.host, self.port, self.password) self.client.connect() self.log.info("...Connected to OBS Websockets at {}:{}".format(self.host, self.port)) except Exception as e: self.log.error("Could not initialize connection at {}:{} to OBS Websockets! Exception: {}".format(self.host, self.port, e)) raise
def OBS_StopStreaming(): ws = obsws(host, port, password) try: ws.connect() except: return 1,"Error de Conexion - ¿OBS Parado?)" falcon_logger.info("Parando Streaming") ws.call(requests.StopStreaming()) ws.disconnect() falcon_logger.info("Streaming Parado") # Mata_Proceso("obs") # falcon_logger.info("OBS Matado") return 0,"Ok"
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 run(): socket = obsws(config.WEBSOCKET_HOST, config.WEBSOCKET_PORT, config.WEBSOCKET_PASSWORD) socket.connect() process = subprocess.Popen(config.GAME_PATH, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: output = process.stdout.readline() if output == '' or process.poll() is not None: break print('beatoraja:', output.decode().strip()) for search, scene in beatoraja.SCENE_MATCHES.items(): if search in str(output): print('Detected scene', scene) handle(socket, scene) handle(socket, beatoraja.Quit)
def __init__(self, host='localhost', port=4444, password='', verbose=False): self.connection = obsws(host, port, password) self.connection.register(self.on_event) self.connection.connect() if verbose: sources = self.connection.call( requests.GetSourcesList()).getSources() print('Sources detected:') for source in sources: print(' - {}'.format(source['name']))
def OBS_Lista_Escenas(): falcon_logger.info("Lista Escenas") ws = obsws(host, port, password) lista=[] try: ws.connect() except: return 1,"Error de Conexion - ¿OBS Parado?)", lista scenes = ws.call(requests.GetSceneList()) for s in scenes.getScenes(): falcon_logger.info(s['name']) lista.append(s['name']) ws.disconnect() return 0,"OK",lista
def __init__(self, switch_handler=None, webcam_handler=None): try: with open('.config.json', 'r') as cfg: config = json.load(cfg) self.ws = obsws(host=config['host'], port=config['port'], password=config['password']) if switch_handler: self.ws.register(switch_handler, events.SwitchScenes) if webcam_handler: self.ws.register(webcam_handler, events.SceneItemVisibilityChanged) self.ws.connect() except FileNotFoundError: print(".config.json not found")