def populate_scene_lists(lists): scene_names = obs.obs_frontend_get_scene_names() for l in lists: obs.obs_property_list_clear(l) obs.obs_property_list_add_string(l, "", "") for name in scene_names: obs.obs_property_list_add_string(l, name, name)
def script_properties(): props = obs.obs_properties_create() scenes = obs.obs_frontend_get_scene_names() scene_select = obs.obs_properties_add_list(props, "template_scene_name", "Scene to use as a template", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) for scene in scenes: obs.obs_property_list_add_string(scene_select, scene, scene) obs.obs_properties_add_path(props, 'image_directory', 'Image directory', obs.OBS_PATH_DIRECTORY, '', '') obs.obs_properties_add_button(props, "button", "Import", run_import) return props
def open_gui(*args): global app global globSettings app.show() currentScene = obs.obs_frontend_get_current_scene() sceneName = obs.obs_source_get_name(currentScene) obs.obs_data_set_string(globSettings, "scene", sceneName) obs.obs_source_release(currentScene) scenes = obs.obs_frontend_get_scene_names() result = [] if scenes is not None: for scene in scenes: result.append(scene) app.scenes = tuple(result) app.scene.set(sceneName) app.update()
def update(): global url try: with urllib.request.urlopen(url) as response: data = response.read() response = json.loads(data) _scenes = zip(obs.obs_frontend_get_scene_names(), obs.obs_frontend_get_scenes()) scenes = {} for scene in _scenes: scenes[scene[0]] = scene[1] if scenes.get(response['camera']) is not None: print("Switching to scene: " + response['camera']) obs.obs_frontend_set_current_scene(scenes[response['camera']]) except urllib.error.URLError as err: obs.script_log(obs.LOG_WARNING, "Error opening URL '" + url + "': " + err.reason) obs.remove_current_callback()
def script_properties(): props = obs.obs_properties_create() p = obs.obs_properties_add_list(props, "slide_scene", "Slide Scene", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_list_add_string(p, "--Disabled--", "") scene_names = obs.obs_frontend_get_scene_names() if scene_names != None: for scene_name in scene_names: obs.obs_property_list_add_string(p, scene_name, scene_name) p = obs.obs_properties_add_list(props, "monitor", "Monitor", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) for i, monitor in enumerate(monitors): obs.obs_property_list_add_int(p, str(monitor.szDevice), i) p = obs.obs_properties_add_list(props, "screen_sourcename", "Screen Source", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_list_add_string(p, "--Disabled--", "") sources = obs.obs_enum_sources() if sources != None: for source in sources: name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(p, name, name) obs.source_list_release(sources) obs.obs_properties_add_int_slider(props, "slide_visible_duration", "Slide Visible Duration", 5, 120, 5) obs.obs_properties_add_float_slider(props, "fadeout_duration", "Fade Out Duration", 0.05, 1.25, 0.05) obs.obs_properties_add_float_slider(props, "refresh_interval", "Refresh Interval", 0.1, 5, 0.1) obs.obs_properties_add_int_slider(props, "camera_blur", "Camera Blur", 1, 128, 1) p = obs.obs_properties_add_list(props, "camera_sourcename", "Camera Source", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_list_add_string(p, "--Disabled--", "") sources = obs.obs_enum_sources() if sources != None: for source in sources: name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(p, name, name) obs.source_list_release(sources) return props
def script_tick(tick): global globSettings global animationInfo global animationRunning global app global currentScene if animationRunning: animationInfo["animTime"] += tick animationInfo["animTime"] = min(animationInfo["animTime"], animationInfo["stopTime"]) scaleFactor = easeInOutQuad( animationInfo["animTime"] / animationInfo["stopTime"], 0, 1, 1) animScene = animationInfo["animScene"] initial = animationInfo["initial"] destination = animationInfo["destination"] result = [] sceneObject = obs.obs_scene_from_source(animScene) if obs.obs_source_get_name( animScene) in obs.obs_frontend_get_scene_names(): items = obs.obs_scene_enum_items(sceneObject) for i in range(len(initial)): pos = obs.vec2() pos.x = scaleFactor * (destination[i]["pos"][0] - initial[i] ["pos"][0]) + initial[i]["pos"][0] pos.y = scaleFactor * (destination[i]["pos"][1] - initial[i] ["pos"][1]) + initial[i]["pos"][1] rot = scaleFactor * (destination[i]["rot"] - initial[i]["rot"]) + initial[i]["rot"] scale = obs.vec2() scale.x = scaleFactor * ( destination[i]["scale"][0] - initial[i]["scale"][0]) + initial[i]["scale"][0] scale.y = scaleFactor * ( destination[i]["scale"][1] - initial[i]["scale"][1]) + initial[i]["scale"][1] alignment = destination[i]["alignment"] bounds = obs.vec2() bounds.x = scaleFactor * ( destination[i]["bounds"][0] - initial[i]["bounds"][0]) + initial[i]["bounds"][0] bounds.y = scaleFactor * ( destination[i]["bounds"][1] - initial[i]["bounds"][1]) + initial[i]["bounds"][1] boundsType = destination[i]["boundsType"] boundsAlignment = destination[i]["boundsAlignment"] crop = obs.obs_sceneitem_crop() crop.left = math.floor( scaleFactor * (destination[i]["crop"][0] - initial[i]["crop"][0]) + initial[i]["crop"][0]) crop.right = math.floor( scaleFactor * (destination[i]["crop"][1] - initial[i]["crop"][1]) + initial[i]["crop"][1]) crop.top = math.floor( scaleFactor * (destination[i]["crop"][2] - initial[i]["crop"][2]) + initial[i]["crop"][2]) crop.bottom = math.floor( scaleFactor * (destination[i]["crop"][3] - initial[i]["crop"][3]) + initial[i]["crop"][3]) obs.obs_sceneitem_set_pos(items[i], pos) obs.obs_sceneitem_set_rot(items[i], rot) obs.obs_sceneitem_set_scale(items[i], scale) obs.obs_sceneitem_set_alignment(items[i], alignment) obs.obs_sceneitem_set_bounds(items[i], bounds) obs.obs_sceneitem_set_bounds_type(items[i], boundsType) obs.obs_sceneitem_set_bounds_alignment(items[i], boundsAlignment) obs.obs_sceneitem_set_crop(items[i], crop) obs.sceneitem_list_release(items) #obs.obs_scene_release(sceneObject) if animationInfo["animTime"] == animationInfo["stopTime"]: obs.obs_source_release(animScene) animationInfo["animScene"] = None animationRunning = False
def script_properties(): props = obs.obs_properties_create() p = obs.obs_properties_add_bool(props, "manage_streaming", "Manage Streaming") obs.obs_property_set_modified_callback(p, on_property_modified) p = obs.obs_properties_add_bool(props, "manage_recording", "Manage Recording") obs.obs_property_set_modified_callback(p, on_property_modified) auto_start_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "auto_start_group", "Auto Start", obs.OBS_GROUP_NORMAL, auto_start_group) p = obs.obs_properties_add_list(auto_start_group, "start_scene", "Start Scene", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_set_enabled(p, manage_streaming or manage_recording) obs.obs_property_set_modified_callback(p, on_property_modified) obs.obs_property_list_add_string(p, "--Disabled--", "") scene_names = obs.obs_frontend_get_scene_names() if scene_names != None: for scene_name in scene_names: obs.obs_property_list_add_string(p, scene_name, scene_name) schedule_group = obs.obs_properties_create() obs.obs_properties_add_group(auto_start_group, "schedule_group", "Schedule", obs.OBS_GROUP_NORMAL, schedule_group) p = obs.obs_properties_add_list(schedule_group, "weekday", "Day of Week", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) obs.obs_property_set_enabled(p, (manage_streaming or manage_recording) and start_scene != "") for i, day_of_week in enumerate(days_of_week): obs.obs_property_list_add_int(p, day_of_week, i) p = obs.obs_properties_add_list(schedule_group, "preshow_duration", "Livestream Start", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) obs.obs_property_set_enabled(p, (manage_streaming or manage_recording) and start_scene != "") obs.obs_property_list_clear(p) for i in range(4): seconds = i * 60 * 5 obs.obs_property_list_add_int( p, time(hour=math.floor((event_start - seconds) / 60 / 60), minute=int( (event_start - seconds) / 60 % 60)).strftime("%I:%M %p"), seconds) p = obs.obs_properties_add_list(schedule_group, "event_start", "Event Start", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) obs.obs_property_set_enabled(p, (manage_streaming or manage_recording) and start_scene != "") obs.obs_property_set_modified_callback(p, event_start_list_modified) for i in range(288): obs.obs_property_list_add_int( p, time(hour=math.floor(i / 12), minute=(i % 12) * 5).strftime("%I:%M %p"), int((i / 12) * 60 * 60)) text_source_list = obs.obs_properties_add_list(auto_start_group, "text_source", "Text Source", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_set_enabled(text_source_list, (manage_streaming or manage_recording) and start_scene != "") obs.obs_property_set_modified_callback(text_source_list, on_property_modified) obs.obs_property_list_add_string(text_source_list, "--Disabled--", "") sources = obs.obs_enum_sources() if sources != None: for source in sources: source_id = obs.obs_source_get_unversioned_id(source) if source_id == "text_gdiplus" or source_id == "text_ft2_source": name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(text_source_list, name, name) obs.source_list_release(sources) p = obs.obs_properties_add_text(auto_start_group, "countdown_final_text", "Countdown Final Text", obs.OBS_TEXT_DEFAULT) obs.obs_property_set_enabled(p, (manage_streaming or manage_recording) and text_source != "" and start_scene != "") auto_stop_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "auto_stop_group", "Auto Stop", obs.OBS_GROUP_NORMAL, auto_stop_group) p = obs.obs_properties_add_list(auto_stop_group, "closing_scene", "Closing Scene", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_set_enabled(p, manage_streaming or manage_recording) obs.obs_property_set_modified_callback(p, closing_scene_modified) obs.obs_property_list_add_string(p, "--Disabled--", "") scene_names = obs.obs_frontend_get_scene_names() if scene_names != None: for scene_name in scene_names: obs.obs_property_list_add_string(p, scene_name, scene_name) p = obs.obs_properties_add_int(auto_stop_group, "stop_streaming_delay", "Streaming Delay", 0, 300, 15) obs.obs_property_set_enabled(p, manage_streaming and closing_scene != "") p = obs.obs_properties_add_int(auto_stop_group, "stop_recording_delay", "Recording Delay", 0, 120, 5) obs.obs_property_set_enabled(p, manage_recording and closing_scene != "") return props