Skip to content

rse/obs-cam-control

Repository files navigation

OBS Cam Control

Camera Control for OBS Studio

About

This is a small software solution for controlling the view of multiple Birddog P400 cameras (providing 4K resolution and Pan-Tilt-Zoom (PTZ) functionality) from within the audio/video mixing software OBS Studio. It provides a physical and virtual camera view for each device.

The physical camera views use the Birddog REST API of the camera to recall presets, either previously created with a Birddog PTZ Keyboard or with the OBS PTZ Controls plugin. The physical camera view is intended for regular PTZ uses on non-greenscreen backgrounds.

The virtual camera views are intended for virtualized PTZ uses on greenscreen backgrounds where you cannot use the camera PTZ functionality, because different angles and zoom-levels would require the background to adjust simultanously. Instead, we use the OBS Studio Crop/Pad filter to carve out a Full-HD area from the Chroma Key filtered camera video and a companion background source. In case of multiple cameras, each camera view usually has to get its own dedicated background, usually an angle-consistent pre-rendered view from a 3D scene.

The solution technically consists of two parts: a HTML5 Single-Page-Application (SPA) and a companion OBS Studio source filter. The SPA is intended to be running inside a Browser Source which has to be part of a special "control scene", docked into the OBS Studio user interface through OBS Source Dock and communicating with OBS Studio via OBS WebSocket.

Setup

The particular, original setup is the following:

  • You are producing your live-event with OBS Studio as your free video streaming software.

  • You have the OBS WebSocket, OBS Source Dock, and StreamFX extension plugins installed and activated in OBS Studio.

  • You have OBS Studio configured for Full-HD (1920x1080px) video output (see SettingsVideoBase (Canvas) Resolution).

  • You have a Birddog P400 as the physical camera, connected through SDI or NDI.

  • You have a scene collection in OBS Studio configured, which contains at least the following additional scenes for your camera (here named CAM1 as an example):

    • scene Shared-CAM1-Full:
      (rationale: scene for "full/total" camera view)
      • source CAM1-Full of type Blackmagic Device (SDI) or NDI Source (NDI):
        • attached to your physical 4K camera device
          (rationale: single source for physical camera)
        • transform of Stretch to Screen applied
          (rationale: provide "full/total" camera view in 1080p of Shared-CAM1-Full)
    • scene Shared-CAM1-Zoom:
      (rationale: scene for "zoomed" camera view)
      • source CAM1-Zoom-FG of type Source Mirror:
        • attached to source CAM1-Full
          (rationale: single source for physical camera)
        • filter Chrome Key applied
          (rationale: single filter for chroma-key)
        • filter Crop/Pad applied
          (rationale: the zoom to be applied and controlled)
        • filter Scaling/Aspect Ratio applied (for 1920x1080px) (rationale: ensure result is still Full-HD, even on arbitrary crop areas)
      • source CAM1-Zoom-BG of type Image:
        • attached to your 4K background image
          (rationale: single source for virtual background)
        • filter Scaling/Aspect Ratio applied (for 3820x2160)
          (rationale: ensure the background starts as 4K)
        • filter Crop/Pad applied
          (rationale: the zoom to be applied and controlled)
        • filter Scaling/Aspect Ratio applied (for 1920x1080px)
          (rationale: ensure result is still Full-HD, even on arbitrary crop areas)
    • scene Shared-CAM1-Control:
      (rationale: scene for cam control dock)
      • source CAM1-Control-CC of type Browser Source:
        • loading the OBS Cam Control SPA according to the URL below
          (rationale: running the SPA)
      • source Shared-CAM1-Full of type Scene:
        (rationale: show physical camera in background)
    • scene Shared-CAM1:
      (rationale: view of all full physical cameras)
      • source Shared-CAM1-Full of type Scene
      • source Shared-CAM1-Zoom of type Scene
    • scene Shared-CAM:
      (rationale: view of all full and zoomed cameras)
      • source Shared-CAM1 of type Scene
      • source Shared-CAM2 of type Scene
      • source Shared-CAM3 of type Scene
    • scene Scene-01:
      (rationale: particular event scene based on the full physical camera view)
      • source Shared-CAM of type Scene
        (rationale: include camera view)
    • scene Scene-02:
      (rationale: particular event scene based on the zoomed virtual camera view)
      • source Shared-CAM1 of type Source Mirror
        (rationale: include zoomed camera view)
        • filter Camera Control applied
          (rationale: automatically control camera)
          • parameter Source Name of Control UI set to CAM1-Control-CC
          • parameter Activate Camera on PROGRAM set to no
  • The URL (show-casing all parameters) for the SPA is like the following (URL parts on first line, descriptions on the second line):

    • file://[...]/obs-cam-control.html
      (path to SPA)
    • ?transparent=true
      (make background transparent)
    • &debug=true
      (log debug information)
    • &websocket-address=localhost:4444
      (endpoint of OBS WebSocket)
    • &websocket-password=XXX
      (authentication for endpoint of OBS WebSocket)
    • &camera-name=CAM1
      (title of the camera)
    • &camera-activate=Shared-CAM:Shared-CAM1,Shared-CAM:Shared-CAM2,Shared-CAM:Shared-CAM3
      (the scene source of the camera for activation)
    • &camera-physical-activate=Shared-CAM1:Shared-CAM1-Full,Shared-CAM1:Shared-CAM1-Zoom
      (the scene source of the physical camera for full view)
    • &camera-physical-preview=Shared-CAM1-Full:10
      (the source and FPS of the physical camera for preview)
    • &camera-physical-sources=CAM1-Full
      (the sources of the physical camera for active checking)
    • &camera-physical-canvas=3840x2160
      (size of original physical camera view)
    • &camera-physical-device=192.168.0.1
      (IP address of the physical camera API)
    • &camera-physical-presets=1,2,3,4
      (pre-defined physical presets)
    • &camera-virtual-activate=Shared-CAM1:Shared-CAM1-Zoom,Shared-CAM1:Shared-CAM1-Full
      (the scene source of the virtual camera for zoom view)
    • &camera-virtual-sources=CAM1-Zoom-FG,CAM1-Zoom-BG
      (the sources of the Crop/Pad filters of the virtual camera)
    • &camera-virtual-duration=1000,4000,7000
      (transition durations in milliseconds of the virtual camera)
    • &camera-virtual-fps=30,
      (transition smoothness in frames per second of the virtual camera)
    • &camera-virtual-presets=1:0+0/3860x2160,
      (pre-defined total 4K area)
    • 2:0+540/1920x1080,
      (pre-defined Full-HD area middle/left)
    • 3:960+540/1920x1080,
      (pre-defined Full-HD area middle/center)
    • 4:1920+540/1920x1080
      (pre-defined Full-HD area middle/right)

License

Copyright © 2021-2022 Dr. Ralf S. Engelschall
Distributed under GPL 3.0 license

About

Camera Control for OBS Studio

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published