A Python SDK for OBS Studio WebSocket v5.0
—
The ReqClient provides a synchronous interface for sending commands to OBS Studio via WebSocket. All methods correspond to OBS WebSocket v5.0 API calls with snake_case naming and return structured response objects.
class ReqClient:
def __init__(self, host='localhost', port=4455, password='', timeout=None):
"""
Initialize request client.
Parameters:
- host (str): OBS WebSocket host address
- port (int): OBS WebSocket port number
- password (str): OBS WebSocket password
- timeout (float, optional): Connection timeout in seconds
"""
def __enter__(self):
"""Context manager entry."""
def __exit__(self, exc_type, exc_value, exc_traceback):
"""Context manager exit with automatic disconnect."""
def disconnect(self):
"""Close WebSocket connection."""
def send(self, param, data=None, raw=False):
"""
Send raw request to OBS.
Parameters:
- param (str): Request type name
- data (dict, optional): Request data payload
- raw (bool): Return raw JSON instead of dataclass object
Returns:
Response dataclass object or raw dict if raw=True
"""def get_version(self):
"""
Get OBS and WebSocket version information.
Returns:
Object with obs_version, obs_web_socket_version, rpc_version, available_requests, supported_image_formats
"""
def get_stats(self):
"""
Get OBS performance statistics.
Returns:
Object with cpu_usage, memory_usage, free_disk_space, average_frame_time, render_total_frames, etc.
"""
def broadcast_custom_event(self, eventData):
"""
Broadcast custom event to all WebSocket clients.
Parameters:
- eventData (object): Data payload to emit
"""
def call_vendor_request(self, vendor_name, request_type, request_data=None):
"""
Call vendor-specific request.
Parameters:
- vendor_name (str): Name of the vendor
- request_type (str): Request type to call
- request_data (dict, optional): Request data
Returns:
Vendor-specific response data
"""
def sleep(self, sleep_millis=None, sleep_frames=None):
"""
Sleep for a time duration or number of frames (only available in request batches).
Parameters:
- sleep_millis (int, optional): Sleep time in milliseconds
- sleep_frames (int, optional): Sleep time in frames
"""
def get_persistent_data(self, realm, slot_name):
"""
Get value from persistent data realm.
Parameters:
- realm (str): Data realm (OBS_WEBSOCKET_DATA_REALM_*)
- slot_name (str): Name of the slot
Returns:
Object with slot_value
"""
def set_persistent_data(self, realm, slot_name, slot_value):
"""
Set value in persistent data realm.
Parameters:
- realm (str): Data realm (OBS_WEBSOCKET_DATA_REALM_*)
- slot_name (str): Name of the slot
- slot_value: Value to store in slot
"""def get_scene_list(self):
"""
Get list of all scenes.
Returns:
Object with current_program_scene_name, current_preview_scene_name, scenes
"""
def get_current_program_scene(self):
"""
Get current program scene.
Returns:
Object with current_program_scene_name
"""
def set_current_program_scene(self, name):
"""
Set current program scene.
Parameters:
- name (str): Scene name to switch to
"""
def get_current_preview_scene(self):
"""
Get current preview scene.
Returns:
Object with current_preview_scene_name
"""
def set_current_preview_scene(self, name):
"""
Set current preview scene.
Parameters:
- name (str): Scene name to set as preview
"""
def create_scene(self, name):
"""
Create new scene.
Parameters:
- name (str): Name for new scene
"""
def remove_scene(self, name):
"""
Remove scene from OBS.
Parameters:
- name (str): Name of scene to remove
"""
def set_scene_name(self, old_name, new_name):
"""
Rename scene.
Parameters:
- old_name (str): Current scene name
- new_name (str): New scene name
"""def get_group_list(self):
"""
Get list of all groups (groups are special scenes).
Returns:
Object with groups list
"""def get_input_list(self, kind=None):
"""
Get list of all inputs.
Parameters:
- kind (str, optional): Filter by input kind
Returns:
Object with inputs list
"""
def get_input_kind_list(self, unversioned):
"""
Get list of available input kinds.
Parameters:
- unversioned (bool): Return unversioned kind names
Returns:
Object with input_kinds list
"""
def get_special_inputs(self):
"""
Get special input names (Desktop Audio, Mic/Aux, etc.).
Returns:
Object with desktop1, desktop2, mic1, mic2, etc.
"""
def create_input(self, sceneName, inputName, inputKind, inputSettings, sceneItemEnabled):
"""
Create new input and add to scene.
Parameters:
- sceneName (str): Scene to add input to
- inputName (str): Name for new input
- inputKind (str): Input type/kind
- inputSettings (object): Input configuration
- sceneItemEnabled (bool): Enable scene item
Returns:
Object with scene_item_id
"""
def remove_input(self, name):
"""
Remove input.
Parameters:
- name (str): Input name to remove
"""
def set_input_name(self, old_name, new_name):
"""
Rename input.
Parameters:
- old_name (str): Current input name
- new_name (str): New input name
"""def get_input_default_settings(self, kind):
"""
Get default settings for input kind.
Parameters:
- kind (str): Input kind name
Returns:
Object with default_input_settings
"""
def get_input_settings(self, name):
"""
Get input settings.
Parameters:
- name (str): Input name
Returns:
Object with input_settings, input_kind
"""
def set_input_settings(self, name, settings, overlay):
"""
Set input settings.
Parameters:
- name (str): Input name
- settings (dict): Settings to apply
- overlay (bool): Overlay on existing settings or replace
"""def get_input_mute(self, name):
"""
Get input mute state.
Parameters:
- name (str): Input name
Returns:
Object with input_muted
"""
def set_input_mute(self, name, muted):
"""
Set input mute state.
Parameters:
- name (str): Input name
- muted (bool): Mute state
"""
def toggle_input_mute(self, name):
"""
Toggle input mute state.
Parameters:
- name (str): Input name
Returns:
Object with input_muted (new state)
"""
def get_input_volume(self, name):
"""
Get input volume.
Parameters:
- name (str): Input name
Returns:
Object with input_volume_mul, input_volume_db
"""
def set_input_volume(self, name, vol_mul=None, vol_db=None):
"""
Set input volume.
Parameters:
- name (str): Input name
- vol_mul (float, optional): Volume multiplier (0-20)
- vol_db (float, optional): Volume in dB (-100 to 26)
"""
def get_input_audio_balance(self, name):
"""
Get audio balance.
Parameters:
- name (str): Input name
Returns:
Object with input_audio_balance
"""
def set_input_audio_balance(self, name, balance):
"""
Set audio balance.
Parameters:
- name (str): Input name
- balance (float): Balance value (0.0-1.0)
"""
def get_input_audio_sync_offset(self, name):
"""
Get audio sync offset.
Parameters:
- name (str): Input name
Returns:
Object with input_audio_sync_offset
"""
def set_input_audio_sync_offset(self, name, offset):
"""
Set audio sync offset.
Parameters:
- name (str): Input name
- offset (int): Offset in milliseconds (-950 to 20000)
"""
def get_input_audio_monitor_type(self, name):
"""
Get audio monitor type.
Parameters:
- name (str): Input name
Returns:
Object with monitor_type
"""
def set_input_audio_monitor_type(self, name, mon_type):
"""
Set audio monitor type.
Parameters:
- name (str): Input name
- mon_type (int): Monitor type (OBS_MONITORING_TYPE_*)
"""
def get_input_audio_tracks(self, name):
"""
Get audio track enable states.
Parameters:
- name (str): Input name
Returns:
Object with input_audio_tracks dict
"""
def set_input_audio_tracks(self, name, track):
"""
Set audio track enable states.
Parameters:
- name (str): Input name
- track (dict): Track enable states
"""
def get_input_properties_list_property_items(self, input_name, property_name):
"""
Get items of a list property from input's properties.
Parameters:
- input_name (str): Input name
- property_name (str): Property name
Returns:
Object with property_items list
"""
def press_input_properties_button(self, input_name, property_name):
"""
Press a button in input properties.
Parameters:
- input_name (str): Input name
- property_name (str): Button property name
"""def get_scene_item_list(self, name):
"""
Get scene items in scene.
Parameters:
- name (str): Scene name
Returns:
Object with scene_items list
"""
def get_scene_item_id(self, scene_name, source_name, offset=None):
"""
Get scene item ID by source name.
Parameters:
- scene_name (str): Scene name
- source_name (str): Source name to find
- offset (int, optional): Search offset
Returns:
Object with scene_item_id
"""
def create_scene_item(self, scene_name, source_name, enabled=None):
"""
Add existing source to scene.
Parameters:
- scene_name (str): Scene name
- source_name (str): Source name to add
- enabled (bool, optional): Enable state
Returns:
Object with scene_item_id
"""
def remove_scene_item(self, scene_name, item_id):
"""
Remove scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
"""
def duplicate_scene_item(self, scene_name, item_id, dest_scene_name=None):
"""
Duplicate scene item.
Parameters:
- scene_name (str): Source scene name
- item_id (int): Scene item ID
- dest_scene_name (str, optional): Destination scene
Returns:
Object with scene_item_id
"""def get_scene_item_enabled(self, scene_name, item_id):
"""
Get scene item enabled state.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with scene_item_enabled
"""
def set_scene_item_enabled(self, scene_name, item_id, enabled):
"""
Set scene item enabled state.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
- enabled (bool): Enable state
"""
def get_scene_item_locked(self, scene_name, item_id):
"""
Get scene item locked state.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with scene_item_locked
"""
def set_scene_item_locked(self, scene_name, item_id, locked):
"""
Set scene item locked state.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
- locked (bool): Lock state
"""
def get_scene_item_transform(self, scene_name, item_id):
"""
Get scene item transform and crop info.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with scene_item_transform containing position, rotation, scale, crop, etc.
"""
def set_scene_item_transform(self, scene_name, item_id, transform):
"""
Set scene item transform.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
- transform (dict): Transform settings
"""
def get_group_scene_item_list(self, group_name):
"""
Get scene items in a group.
Parameters:
- group_name (str): Group name
Returns:
Object with scene_items list
"""
def get_scene_item_source(self, scene_name, item_id):
"""
Get source associated with a scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with source_name and source_type
"""
def get_scene_item_index(self, scene_name, item_id):
"""
Get index position of a scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with scene_item_index
"""
def set_scene_item_index(self, scene_name, item_id, index):
"""
Set index position of a scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
- index (int): New index position
"""
def get_scene_item_blend_mode(self, scene_name, item_id):
"""
Get blend mode of a scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
Returns:
Object with scene_item_blend_mode
"""
def set_scene_item_blend_mode(self, scene_name, item_id, blend_mode):
"""
Set blend mode of a scene item.
Parameters:
- scene_name (str): Scene name
- item_id (int): Scene item ID
- blend_mode (str): Blend mode (Normal, Additive, Subtract, Screen, Multiply, etc.)
"""def get_stream_status(self):
"""
Get stream output status.
Returns:
Object with output_active, output_reconnecting, output_timecode, output_duration, etc.
"""
def toggle_stream(self):
"""
Toggle streaming state.
Returns:
Object with output_active
"""
def start_stream(self):
"""Start streaming."""
def stop_stream(self):
"""Stop streaming."""
def send_stream_caption(self, caption):
"""
Send CEA-608 caption text.
Parameters:
- caption (str): Caption text
"""def get_record_status(self):
"""
Get recording output status.
Returns:
Object with output_active, output_paused, output_timecode, output_duration, etc.
"""
def toggle_record(self):
"""
Toggle recording state.
Returns:
Object with output_active
"""
def start_record(self):
"""Start recording."""
def stop_record(self):
"""
Stop recording.
Returns:
Object with output_path
"""
def pause_record(self):
"""Pause recording."""
def resume_record(self):
"""Resume recording."""
def toggle_record_pause(self):
"""Toggle recording pause state."""
def split_record_file(self):
"""Split current recording into new file."""
def create_record_chapter(self, chapter_name=None):
"""
Add chapter marker to recording.
Parameters:
- chapter_name (str, optional): Chapter name
"""
def get_record_directory(self):
"""
Get recording output directory.
Returns:
Object with record_directory
"""
def set_record_directory(self, recordDirectory):
"""
Set recording output directory.
Parameters:
- recordDirectory (str): Output directory path
"""def get_virtual_cam_status(self):
"""
Get virtual camera status.
Returns:
Object with output_active
"""
def start_virtual_cam(self):
"""Start virtual camera."""
def stop_virtual_cam(self):
"""Stop virtual camera."""
def toggle_virtual_cam(self):
"""
Toggle virtual camera.
Returns:
Object with output_active
"""def get_replay_buffer_status(self):
"""
Get replay buffer status.
Returns:
Object with output_active
"""
def start_replay_buffer(self):
"""Start replay buffer."""
def stop_replay_buffer(self):
"""Stop replay buffer."""
def toggle_replay_buffer(self):
"""
Toggle replay buffer.
Returns:
Object with output_active
"""
def save_replay_buffer(self):
"""Save replay buffer to file."""
def get_last_replay_buffer_replay(self):
"""
Get last replay buffer save path.
Returns:
Object with saved_replay_path
"""def get_scene_collection_list(self):
"""
Get array of all scene collections.
Returns:
Object with scene_collections list
"""
def set_current_scene_collection(self, name):
"""
Switch to a scene collection.
Parameters:
- name (str): Name of scene collection to switch to
"""
def create_scene_collection(self, name):
"""
Create new scene collection and switch to it.
Note: This blocks until collection has finished changing.
Parameters:
- name (str): Name for new scene collection
"""def get_profile_list(self):
"""
Get list of all profiles.
Returns:
Object with profiles list
"""
def set_current_profile(self, name):
"""
Switch to a profile.
Parameters:
- name (str): Name of profile to switch to
"""
def create_profile(self, name):
"""
Create new profile and switch to it.
Parameters:
- name (str): Name for new profile
"""
def remove_profile(self, name):
"""
Remove a profile. If current profile is chosen, switches to different profile first.
Parameters:
- name (str): Name of profile to remove
"""
def get_profile_parameter(self, category, name):
"""
Get parameter from current profile's configuration.
Parameters:
- category (str): Parameter category
- name (str): Parameter name
Returns:
Object with parameter_value and default_parameter_value
"""
def set_profile_parameter(self, category, name, value):
"""
Set parameter value in current profile's configuration.
Parameters:
- category (str): Parameter category
- name (str): Parameter name
- value (str): Parameter value (use None to delete)
"""def get_video_settings(self):
"""
Get current video settings.
Returns:
Object with fps_numerator, fps_denominator, base_width, base_height, output_width, output_height
"""
def set_video_settings(self, fps_numerator=None, fps_denominator=None, base_width=None, base_height=None, output_width=None, output_height=None):
"""
Set video settings.
Parameters:
- fps_numerator (int, optional): Numerator of FPS fraction
- fps_denominator (int, optional): Denominator of FPS fraction
- base_width (int, optional): Base canvas width
- base_height (int, optional): Base canvas height
- output_width (int, optional): Output width
- output_height (int, optional): Output height
"""
def get_stream_service_settings(self):
"""
Get current stream service settings.
Returns:
Object with stream_service_type and stream_service_settings
"""
def set_stream_service_settings(self, ss_type, ss_settings):
"""
Set stream service settings.
Parameters:
- ss_type (str): Stream service type
- ss_settings (dict): Stream service settings
"""def get_transition_kind_list(self):
"""
Get array of all available transition kinds.
Returns:
Object with transition_kinds list
"""
def get_scene_transition_list(self):
"""
Get array of all scene transitions in OBS.
Returns:
Object with scene_transitions list
"""
def get_current_scene_transition(self):
"""
Get current scene transition information.
Returns:
Object with transition_name, transition_kind, transition_duration, transition_fixed, transition_configurable, transition_settings
"""
def set_current_scene_transition(self, name):
"""
Set current scene transition.
Note: While transition namespace is generally unique, uniqueness is not guaranteed.
Parameters:
- name (str): Name of transition to make active
"""
def set_current_scene_transition_duration(self, duration):
"""
Set duration of current scene transition, if not fixed.
Parameters:
- duration (int): Duration in milliseconds (50-20000)
"""
def set_current_scene_transition_settings(self, settings, overlay=None):
"""
Set settings of current scene transition.
Parameters:
- settings (dict): Settings object to apply (can be empty dict)
- overlay (bool, optional): Whether to overlay over current settings or replace them
"""
def get_current_scene_transition_cursor(self):
"""
Get cursor position of current scene transition.
Note: Returns 1.0 when transition is inactive.
Returns:
Object with transition_cursor (0.0-1.0)
"""
def trigger_studio_mode_transition(self):
"""
Trigger current scene transition (same as Transition button in studio mode).
Note: Studio mode must be active or throws StudioModeNotActive error.
"""
def set_t_bar_position(self, pos, release=None):
"""
Set position of TBar.
Warning: This will be deprecated in future obs-websocket version.
Parameters:
- pos (float): New position (0.0-1.0)
- release (bool, optional): Whether to release TBar (only set False if sending another position update)
"""def get_studio_mode_enabled(self):
"""
Get whether studio mode is enabled.
Returns:
Object with studio_mode_enabled
"""
def set_studio_mode_enabled(self, enabled):
"""
Enable or disable studio mode.
Parameters:
- enabled (bool): Enable studio mode
"""def get_output_list(self):
"""
Get list of available outputs.
Returns:
Object with outputs list
"""
def get_output_status(self, name):
"""
Get status of an output.
Parameters:
- name (str): Output name
Returns:
Object with output_active and other status information
"""
def toggle_output(self, name):
"""
Toggle status of an output.
Parameters:
- name (str): Output name
Returns:
Object with output_active (new state)
"""
def start_output(self, name):
"""
Start an output.
Parameters:
- name (str): Output name
"""
def stop_output(self, name):
"""
Stop an output.
Parameters:
- name (str): Output name
"""
def get_output_settings(self, name):
"""
Get settings of an output.
Parameters:
- name (str): Output name
Returns:
Object with output_settings
"""
def set_output_settings(self, name, settings):
"""
Set settings of an output.
Parameters:
- name (str): Output name
- settings (dict): Output settings
"""def get_source_active(self, name):
"""
Get active and show state of a source.
Parameters:
- name (str): Source name
Returns:
Object with video_active and video_showing
"""
def get_source_screenshot(self, name, img_format, width=None, height=None, quality=None):
"""
Get Base64-encoded screenshot of a source.
Parameters:
- name (str): Source name
- img_format (str): Image format (jpg, png, bmp, tga, etc.)
- width (int, optional): Screenshot width
- height (int, optional): Screenshot height
- quality (int, optional): Quality for jpg format (0-100)
Returns:
Object with image_data (Base64 string)
"""
def save_source_screenshot(self, name, img_format, file_path, width=None, height=None, quality=None):
"""
Save screenshot of a source to file.
Parameters:
- name (str): Source name
- img_format (str): Image format (jpg, png, bmp, tga, etc.)
- file_path (str): Path to save screenshot
- width (int, optional): Screenshot width
- height (int, optional): Screenshot height
- quality (int, optional): Quality for jpg format (0-100)
"""def get_media_input_status(self, name):
"""
Get status of a media input.
Parameters:
- name (str): Media input name
Returns:
Object with media_state, media_duration, media_cursor
"""
def set_media_input_cursor(self, name, cursor):
"""
Set cursor position of a media input.
Parameters:
- name (str): Media input name
- cursor (int): Cursor position in milliseconds
"""
def offset_media_input_cursor(self, name, offset):
"""
Offset cursor position of a media input.
Parameters:
- name (str): Media input name
- offset (int): Offset in milliseconds (can be negative)
"""
def trigger_media_input_action(self, name, action):
"""
Trigger action on a media input.
Parameters:
- name (str): Media input name
- action (str): Action to trigger (Play, Pause, Stop, Restart, Next, Previous)
"""def get_hot_key_list(self):
"""
Get available hotkeys.
Returns:
Object with hotkeys list
"""
get_hotkey_list = get_hot_key_list # Alias
def trigger_hot_key_by_name(self, hotkeyName, contextName=None):
"""
Trigger hotkey by name.
Parameters:
- hotkeyName (str): Hotkey name
- contextName (str, optional): Context name
"""
trigger_hotkey_by_name = trigger_hot_key_by_name # Alias
def trigger_hot_key_by_key_sequence(self, keyId, pressShift=None, pressCtrl=None, pressAlt=None, pressCmd=None):
"""
Trigger hotkey by key sequence.
Parameters:
- keyId (str): OBS key ID
- pressShift (bool, optional): Press Shift modifier
- pressCtrl (bool, optional): Press Ctrl modifier
- pressAlt (bool, optional): Press Alt modifier
- pressCmd (bool, optional): Press Cmd modifier (Mac)
"""
trigger_hotkey_by_key_sequence = trigger_hot_key_by_key_sequence # Alias
get_hotkey_list = get_hot_key_list # Alias
trigger_hotkey_by_name = trigger_hot_key_by_name # Aliasdef get_source_filter_list(self, name):
"""
Get source filters.
Parameters:
- name (str): Source name
Returns:
Object with filters list
"""
def create_source_filter(self, source_name, filter_name, filter_kind, filter_settings=None):
"""
Create source filter.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
- filter_kind (str): Filter type
- filter_settings (dict, optional): Filter settings
"""
def remove_source_filter(self, source_name, filter_name):
"""
Remove source filter.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
"""
def set_source_filter_enabled(self, source_name, filter_name, enabled):
"""
Enable/disable source filter.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
- enabled (bool): Enable state
"""
def get_source_filter_kind_list(self):
"""
Get array of all available source filter kinds.
Returns:
Object with source_filter_kinds list
"""
def get_source_filter_default_settings(self, filter_kind):
"""
Get default settings for a filter kind.
Parameters:
- filter_kind (str): Filter kind name
Returns:
Object with default_filter_settings
"""
def get_source_filter(self, source_name, filter_name):
"""
Get information for a specific source filter.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
Returns:
Object with filter_enabled, filter_index, filter_kind, filter_settings
"""
def set_source_filter_name(self, source_name, old_filter_name, new_filter_name):
"""
Set name of a source filter (rename).
Parameters:
- source_name (str): Source name
- old_filter_name (str): Current filter name
- new_filter_name (str): New filter name
"""
def set_source_filter_index(self, source_name, filter_name, index):
"""
Set index position of a filter on a source.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
- index (int): New filter index
"""
def set_source_filter_settings(self, source_name, filter_name, settings, overlay=None):
"""
Set settings of a source filter.
Parameters:
- source_name (str): Source name
- filter_name (str): Filter name
- settings (dict): Filter settings
- overlay (bool, optional): Overlay on existing settings or replace
"""def open_input_properties_dialog(self, input_name):
"""
Open properties dialog of an input.
Parameters:
- input_name (str): Input name
"""
def open_input_filters_dialog(self, input_name):
"""
Open filters dialog of an input.
Parameters:
- input_name (str): Input name
"""
def open_input_interact_dialog(self, input_name):
"""
Open interact dialog of an input.
Parameters:
- input_name (str): Input name
"""def get_monitor_list(self):
"""
Get list of connected monitors.
Returns:
Object with monitors list
"""
def open_video_mix_projector(self, video_mix_type, monitor_index=None, projector_geometry=None):
"""
Open projector for specific output video mix.
Parameters:
- video_mix_type (str): Video mix type (OBS_WEBSOCKET_VIDEO_MIX_TYPE_*)
- monitor_index (int, optional): Monitor index (-1 for windowed)
- projector_geometry (str, optional): Projector geometry in format "x,y,width,height"
"""
def open_source_projector(self, source_name, monitor_index=None, projector_geometry=None):
"""
Open projector for a source.
Parameters:
- source_name (str): Source name
- monitor_index (int, optional): Monitor index (-1 for windowed)
- projector_geometry (str, optional): Projector geometry in format "x,y,width,height"
"""import obsws_python as obs
with obs.ReqClient() as client:
# Get current scene information
current = client.get_current_program_scene()
print(f"Current scene: {current.current_program_scene_name}")
# Create and switch to new scene
client.create_scene("My New Scene")
client.set_current_program_scene("My New Scene")
# Add existing source to scene
result = client.create_scene_item("My New Scene", "Mic/Aux", enabled=True)
scene_item_id = result.scene_item_id
# Configure scene item
client.set_scene_item_locked("My New Scene", scene_item_id, False)
# Get scene item transform
transform = client.get_scene_item_transform("My New Scene", scene_item_id)
print(f"Item position: {transform.scene_item_transform}")import obsws_python as obs
with obs.ReqClient() as client:
# Check current mute state
mute_state = client.get_input_mute("Mic/Aux")
print(f"Mic muted: {mute_state.input_muted}")
# Toggle mute and get new state
new_state = client.toggle_input_mute("Mic/Aux")
print(f"Mic now muted: {new_state.input_muted}")
# Set volume to 50%
client.set_input_volume("Mic/Aux", vol_mul=0.5)
# Get current volume
volume = client.get_input_volume("Mic/Aux")
print(f"Volume: {volume.input_volume_mul} ({volume.input_volume_db}dB)")Install with Tessl CLI
npx tessl i tessl/pypi-obsws-python