• OBS Studio -> Tools -> WebSockets Server Settings 필수!
  • https://github.com/obsproject
  • https://github.com/obsproject/obs-websocket
  • https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
  • https://pypi.org/project/obsws-python/
  • https://github.com/aatikturk/obsws-python
  • ...
import obsws_python

obs_client = obsws_python.ReqClient(host="127.0.0.1", port="4455")

def get_broadcast(client):
    try:
        stats = client.send("GetStats", raw=True)
        stats = str(stats)
        sets = client.send("GetStreamServiceSettings", raw=True)
        sets = str(sets)
    except Exception as e:
        my_logger.error(f"obs.get_broadcast() : e={e}")
        return None
    return f"stats={stats} , sets={sets}"


def post_broadcast(client):
    try:
        stream = client.send("StartStream", raw=True)
        stream = str(stream)
    except Exception as e:
        my_logger.error(f"obs.post_broadcast() : e={e}")
        return None
    return stream


def put_broadcast(client):
    try:
        data = {
            'streamServiceType': 'rtmp_custom',
            'streamServiceSettings': {
                'server': 'rtmp://a.rtmp.youtube.com/live2',
                'key': '유튜브 콘솔 라이브 키',
            },
        }
        sets = client.send("SetStreamServiceSettings", raw=True, data=data)
        sets = str(sets)
    except Exception as e:
        my_logger.error(f"obs.put_broadcast() : e={e}")
        return None
    return sets


"""
{'availableRequests': [
    'PressInputPropertiesButton', 
    'GetHotkeyList', 
    'OpenInputInteractDialog', 
    'SaveSourceScreenshot', 
    'GetVersion', 
    'SetInputName', 
    'SetSceneName', 
    'GetStats', 
    'TriggerStudioModeTransition', 
    'SetInputAudioSyncOffset', 
    'GetSceneCollectionList', 
    'BroadcastCustomEvent', 
    'Sleep', 
    'SetSceneSceneTransitionOverride', 
    'CallVendorRequest', 
    'CreateSceneCollection', 
    'SetStudioModeEnabled', 
    'TriggerHotkeyByName', 
    'OpenVideoMixProjector', 
    'TriggerHotkeyByKeySequence', 
    'GetPersistentData', 
    'SetSceneItemIndex', 
    'SetPersistentData', 
    'SetCurrentSceneCollection', 
    'SetInputMute', 
    'SetCurrentPreviewScene', 
    'SetCurrentProgramScene', 
    'OpenSourceProjector', 
    'GetProfileList', 
    'SetCurrentProfile', 
    'RemoveProfile', 
    'CreateProfile', 
    'GetProfileParameter', 
    'SetProfileParameter', 
    'GetInputPropertiesListPropertyItems', 
    'GetInputAudioBalance', 
    
    'GetStreamServiceSettings', 
    
    'GetVideoSettings', 
    'SetVideoSettings', 
    'SetInputAudioBalance', 
    'SetInputVolume', 
    
    'SetStreamServiceSettings', 
    
    'GetInputDefaultSettings', 
    'GetSpecialInputs', 
    'GetInputKindList', 
    'GetRecordDirectory', 
    'GetInputMute', 
    'GetCurrentPreviewScene', 
    'GetReplayBufferStatus', 
    'GetSourceActive', 
    'GetSourceScreenshot', 
    'GetSourcePrivateSettings', 
    'SetSourcePrivateSettings', 
    'SetSourceFilterEnabled', 
    'GetInputList', 
    'GetSceneList', 
    'GetGroupList', 
    'SetInputSettings', 
    'GetCurrentProgramScene',
    'GetSceneItemId', 
    'RemoveScene', 
    'CreateScene', 
    'GetSceneSceneTransitionOverride', 
    'RemoveInput', 
    'CreateInput', 
    'GetSceneItemLocked', 
    'GetInputSettings', 
    'ToggleInputMute', 
    'SetCurrentSceneTransition', 
    'GetInputVolume', 
    'GetInputAudioSyncOffset', 
    'GetInputAudioMonitorType', 
    'SetInputAudioMonitorType', 
    'StartVirtualCam', 
    'GetInputAudioTracks', 
    'SetInputAudioTracks', 
    'GetTransitionKindList', 
    'GetSceneItemTransform', 
    'GetSceneTransitionList', 
    'GetVirtualCamStatus', 
    'GetCurrentSceneTransition', 
    'SetCurrentSceneTransitionDuration', 
    'SetCurrentSceneTransitionSettings', 
    'GetCurrentSceneTransitionCursor', 
    'SetTBarPosition', 
    'StopOutput', 
    'ToggleOutput', 
    'GetSourceFilterList', 
    'GetSourceFilterDefaultSettings', 
    'CreateSourceFilter', 
    'RemoveSourceFilter', 
    'SetSourceFilterName', 
    'GetSourceFilter', 
    'StopRecord', 
    'ToggleRecord', 
    'SetSourceFilterIndex', 
    'SetSourceFilterSettings', 
    'SetSceneItemTransform', 
    'GetSceneItemList', 
    'GetGroupSceneItemList', 
    'CreateSceneItem', 
    'RemoveSceneItem', 
    'DuplicateSceneItem', 
    'GetSceneItemEnabled', 
    'SetSceneItemEnabled', 
    'SetSceneItemLocked', 
    'GetSceneItemIndex', 
    'StartReplayBuffer', 
    'GetSceneItemBlendMode', 
    'SetSceneItemBlendMode', 
    'GetSceneItemPrivateSettings',
     'SetSceneItemPrivateSettings', 
     'StopVirtualCam', 'ToggleVirtualCam', 'StopReplayBuffer', 'ToggleReplayBuffer', 'SaveReplayBuffer', 'GetLastReplayBufferReplay', 'GetOutputList', 'GetOutputStatus', 'StartOutput',
      'GetOutputSettings', 'SetOutputSettings', 'GetStreamStatus', 'StopStream', 'ToggleStream', 'StartStream', 'SendStreamCaption', 'GetRecordStatus', 'StartRecord', 'ToggleRecordPause', 
      'PauseRecord', 'ResumeRecord', 'SetMediaInputCursor', 'GetMediaInputStatus', 'OffsetMediaInputCursor', 'TriggerMediaInputAction', 'GetStudioModeEnabled', 'OpenInputPropertiesDialog', 
      'OpenInputFiltersDialog', 'GetMonitorList'], 
'obsVersion': '29.1.3', 
'obsWebSocketVersion': '5.2.3', 
'platform': 'windows', 
'platformDescription': 'Windows Server 2022 Version 21H2',
'rpcVersion': 1, 
'supportedImageFormats': ['bmp', 'jpeg', 'jpg', 'pbm', 'pgm', 'png', 'ppm', 'xbm', 'xpm']}
"""

-끝-

'빅브로 들' 카테고리의 다른 글

유튜브와 파이 (youtube-dl, pytube, pytchat, ...)  (0) 2023.11.21
Slack  (0) 2021.06.27
DISCORD  (0) 2021.05.05
sendbird  (0) 2021.04.28
firebase  (0) 2020.12.02

+ Recent posts