Giter Club home page Giter Club logo

obs-mac-virtualcam's Introduction

OBS (macOS) Virtual Camera

Creates a virtual webcam device from the output of OBS. Especially useful for streaming smooth, composited video into Zoom, Hangouts, Jitsi etc. Like CatxFish/obs-virtual-cam but for macOS.

Mar-28-2020 01-55-07

This code was spun out of this OBS Project RFC which was itself spun out of this issue from @tobi. This was intended as a proof of concept to inform technical decisions in that RFC, but who knows, maybe it will be useful to you in its current state. The goal is for this (or something with equivalent functionality) to eventually be merged into the core OBS codebase ๐Ÿคž.

This is heavily based on Apple's CoreMediaIO sample code which has been modernized by @lvsti

Known Issues

  • Resolution is hardcoded to 1280x720
  • If OBS is closed when an app is opened, the virtual camera may not show up
  • Can't click menu bar after program start (OBS Issue #2678). NOTE: This is not an issue with this plugin, but it does make it more difficult to turn on the Virtual Camera created by this plugin.
  • DAL plugin unable to run because of codesigning issues (for example unable to see Virtual Camera in latest version of Zoom). See #4 for a workaround

Reporting Issues / Bugs / Improvements

This plugin is still very much a work in progress. If you are having an issue there's a good chance someone has already run into the same thing. Please search past issues before reporting a new one.

Also please confirm that your issue is related to this plugin and not a general OBS problem before opening an issue -- try to build OBS locally (but not this plugin) and see if the issue persists. If it does, please don't open an issue here; Instead go open an issue on obsproject/obs-studio.

If you still believe you have found an unreported issue related to this plugin, please open an issue! When you do, include any relevant terminal log, crash log, screen recording and/or screenshots.

Building

To use this plugin, you'll need to clone and build OBS locally, build this plugin, copy it to the right places, then run your local build of OBS:

# Clone and build OBS
git clone --recursive https://github.com/obsproject/obs-studio.git
cd obs-studio

# Follow normal OBS build steps
brew install FFmpeg x264 Qt5 cmake mbedtls swig
mkdir build
cd build
export QTDIR=/usr/local/opt/qt
cmake .. && make -j

# Clone this repo
cd ../..
git clone https://github.com/johnboiles/obs-mac-virtualcam.git
cd obs-mac-virtualcam

# Set an environment variable that points to the directory for your OBS clone
export OBS_DIR=$PWD/../obs-studio

# Build the plugin
mkdir build
cd build
cmake -DLIBOBS_INCLUDE_DIR:STRING=$OBS_DIR/libobs -DLIBOBS_LIB:STRING=$OBS_DIR/build/libobs/libobs.dylib -DOBS_FRONTEND_LIB:STRING=$OBS_DIR/build/UI/obs-frontend-api/libobs-frontend-api.dylib -DQTDIR:STRING=/usr/local/opt/qt ..
make -j

# Copy the OBS plugin to your local OBS build
cp src/obs-plugin/obs-mac-virtualcam.so $OBS_DIR/build/rundir/RelWithDebInfo/obs-plugins/

# Remove any existing plugin and copy the DAL plugin to the right place
sudo rm -rf /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin && sudo cp -r src/dal-plugin/obs-mac-virtualcam.plugin /Library/CoreMediaIO/Plug-Ins/DAL

# Run your build of OBS
cd $OBS_DIR/build/rundir/RelWithDebInfo/bin
./obs

Now in OBS go to Tools->Start Virtual Camera, then open your favorite video streaming app (or fully close it then re-open it to make sure it reloads any loaded video plugins). You should be able to pick OBS Virtual Camera as a source.

Development

Please help me make this thing not janky!

Using the cmake Xcode generator

You can use cmake to generate an xcodeproj file to open all the files in Xcode:

# Set an environment variable that points to the directory for your OBS clone
export OBS_DIR=$PWD/../obs-studio
# Set an environment variable pointing to QT
export QTDIR=/usr/local/opt/qt

mkdir xcode
cd xcode
cmake -DLIBOBS_INCLUDE_DIR:STRING=$OBS_DIR/libobs -DLIBOBS_LIB:STRING=$OBS_DIR/build/libobs/libobs.dylib -DOBS_FRONTEND_LIB:STRING=$OBS_DIR/build/UI/obs-frontend-api/libobs-frontend-api.dylib -DQTDIR:STRING=/usr/local/opt/qt -G Xcode ..

You can then use Xcode to build your binaries (which will include debug symbols). To copy them into the right place you need a slightly different command. From the xcode directory created previously:

# Copy over the OBS plugin
cp src/obs-plugin/Debug/obs-mac-virtualcam.so $OBS_DIR/xcode/rundir/Debug/obs-plugins
# Remove any existing plugin and copy the DAL plugin to the right place
sudo rm -rf /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin && sudo cp -r src/dal-plugin/Debug/obs-mac-virtualcam.plugin /Library/CoreMediaIO/Plug-Ins/DAL

Debugging the OBS plugin

To debug the OBS plugin (obs-mac-virtualcam.so), you can attach the Xcode debugger to the OBS process. This allows you to step through the OBS plugin code In Xcode, go to Debug -> Attach to Process by PID or Name..., then enter obs and debug the process as root. Then run OBS and you should be able to hit breakpoints set inside the plugin code.

Debugging the DAL plugin

Debugging the DAL plugin (obs-mac-virtualcam.plugin) is a little trickier. You need to attach the Xcode debugger to a host process that loads the plugin. One option is to build another copy of OBS (without obs-mac-virtualcam.so), attach the debugger to that process, then add the virtual camera as a Video Capture Device there. You should then be able to step through code on the DAL plugin.

License

As the goal of this repo is to eventually get merged into obsproject/obs-studio (or die because someone made a better implementation), the license for this code mirrors the GPLv2 license for that project.

obs-mac-virtualcam's People

Contributors

gep13 avatar gxalpha avatar johnboiles avatar leonelsamayoaup avatar lvsti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.