<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OBS: OSC Scene Switcher - My Version]]></title><description><![CDATA[<p>Dear All,</p>
<p>In preparing for today's guru session I wanted to make use of this <a href="https://github.com/CarloCattano/ObSC"></a><a href="https://github.com/CarloCattano/ObSC" target="_blank">python script hosted on GitHub</a> to allow me to switch scenes in OBS using OSC. Kudos to Carlo Cattano for creating it.</p>
<p>However, I discovered two issues:</p>
<p>1) macOS does not support python scripts :-( The workaround is to run the script in a terminal window.</p>
<p>2) The script itself does not seem to work as one might expect. The description indicates that the single numeric parameter sent after the /Scenes address should select the scene at that index, i.e., 0 selects the first scene, 1 selects the second, etc. But it doesn't seem to work that way. So I made some improvement and fixes to the script as given below. This code below should be replace the code in the ObSC.py file.</p>
<p><a href="/assets/uploads/files/1587541491733-obsc.py.zip">ObSC.py.zip</a></p>
<p>Best Wishes,<br />Mark</p>
<pre>
import sys,time,argparse,math
from pythonosc import dispatcher
from pythonosc import osc_server
import logging
logging.basicConfig(level=logging.INFO)
sys.path.append('../')
from obswebsocket import obsws, requests  # noqa: E402
host = "localhost"
port = 4444
password = "put_your_password_here"
ws = obsws(host, port, password)
ws.connect()
ScenesNames = []
SceneSources = []
def sourceSwitch(source_name,scene,switch):
    ws.call(requests.SetSceneItemProperties(source_name,scene,visible=switch)) 
def is_integer(v):
    try:
        int(v)
        return True;
    except ValueError:
        return False;
def scene_switch(unused_addr, args, oscValue):
<p dir="auto">try:<br />
        if (is_integer(oscValue)):<br />
            print("CMD = '{0}' INDEX = {1} OBS SCENE NAME = '{2}'".format(args[0], oscValue, ScenesNames[int(oscValue)]))<br />
            ws.call(requests.SetCurrentScene(ScenesNames[int(oscValue)]))<br />
            # control sources by using sourceSwitch("source_Name","Scene_name", bool)<br />
            # sourceSwitch("screen1","Scene1",False)<br />
        else:<br />
            print("OSC Value '{0}' cannot be converted to an integer.".format(oscValue))<br />
    except:<br />
        pass<br />
if <strong>name</strong> == "<strong>main</strong>":<br />
    try:<br />
        scenes = ws.call(requests.GetSceneList())<br />
        for s in scenes.getScenes():<br />
            name = s['name']<br />
            print("Adding Scene = '{0}".format(name))<br />
            ScenesNames.append(name)                        # Add every scene to a list of scenes<br />
        print("CURRENT SCENES IN OBS:\n", ScenesNames)<br />
       <br />
        ### OSC SETTINGS<br />
        parser = argparse.ArgumentParser()<br />
        parser.add_argument("--ip", default="127.0.0.1", help="The ip to listen on")<br />
        parser.add_argument("--port", type=int, default=5005, help="The port to listen on")<br />
        args = parser.parse_args()                           # parser for --ip --port arguments<br />
        dispatcher = dispatcher.Dispatcher()<br />
        dispatcher.map("/Scene", scene_switch, "Scene")      # OSC LISTENER<br />
        server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)  <br />
        print("Serving on {}".format(server.server_address))<br />
        <br />
        server.serve_forever()<br />
    except KeyboardInterrupt:<br />
        pass<br />
    ws.disconnect()<br />
  </p></pre><p></p>
]]></description><link>https://community.troikatronix.com/topic/6570/obs-osc-scene-switcher-my-version</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 02:27:54 GMT</lastBuildDate><atom:link href="https://community.troikatronix.com/topic/6570.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Apr 2020 07:36:56 GMT</pubDate><ttl>60</ttl></channel></rss>