Resource icon

macOS Background Removal 0.2.0

sebastianbeckmann

New Member
gxalpha submitted a new resource:

macOS Background Removal - Background removal plugin using macOS' system APIs

This plugin provides a filter to remove a persons background using macOS' built-in Vision API.

The filter can be found in the filters window under "Effect Filters". This means that it can be used on any type of source, not just Video Capture Devices.

If you have support questions, please ask in the #plugins-and-tools channel on the OBS Discord server. Feel free to ping me there (gxalpha#3486).

Read more about this resource...
 
Thank You so much! However it went through the install process, but doesn't show up anywhere. intel mac OS Ventura. Also, I'm not on discord. Sorry. Looking forward to your updates.
 
It was easy to install and a simple interface. It's as good as any virtual green screen I've ever tried. Not sure if the issues can be fixed. With this technology you're dealing with many configurations mostly at home that may need the proper distance, lighting and the right colored cloths to fix these issues. Kudos for taking the time to develop it for the Mac, so I look forward to trying any upgrades you might make. Thanks.
 

sebastianbeckmann

New Member
Thank you for the largely positive feedback!
Which kinds of issues did you run into? If it's with the segmentation not working perfectly it may be possible that it's not fixable on my side, but I'd be happy to look into them.
 
Thank you for the largely positive feedback!
Which kinds of issues did you run into? If it's with the segmentation not working perfectly it may be possible that it's not fixable on my side, but I'd be happy to look into them.
Thank You for quickly attending to my post. I don't know the jargon, but I believe it is the segmentation. It gets worse when you move. However, like I had mentioned before I don't think I've ever used an app that could do it perfectly. I am in a small space that I'm not sure if I could ever get the right lighting for this. When I recorded a video a few years ago I had access to some household lights. After recording with a physical green screen I edited it out in iMovie. It worked out well, but trying to do things live I haven't had the best success. I'll keep trying different configurations. It's a nice plugin though. Thanks so much for your efforts.
 
this plug-in is so good .. for interviews with people who don"t have Green background ...

we can have the same background for the interviewer and the other people ... with our logo !

congratulations !
 

sebastianbeckmann

New Member
sebastianbeckmann updated macOS Background Removal with a new update entry:

Lower mask delay

Updated the mask to have a much lower delay than before. There still is some delay (a bit of which is unfortunately unavoidable), but is better than before.

In theory the filter might now have a higher system resource usage than with version 0.1.0. I did not find a noticeable difference in my testing, but please write a comment in case this poses a problem on your system.

Read the rest of this update entry...
 

yurij

New Member
Hi. Thank you for the great plugin! I wonder if it makes sense to make "mask delay" configurable in the plugin settings. I would love to try even smaller values for it.
 

oracle22

New Member
I've installed the plugin, but don't see it in OBS filter effects. Have opened and closed OBS. Attaching current log file.
MacBook Pro 2019, Ventura 13.4.1


14:01:55.141: [macOS] Permission for audio device access granted.
14:01:55.146: [macOS] Permission for video device access granted.
14:01:55.152: [macOS] Permission for accessibility granted.
14:01:55.162: [macOS] Permission for screen capture granted.
14:01:55.162: CPU Name: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
14:01:55.162: CPU Speed: 2600MHz
14:01:55.162: Physical Cores: 6, Logical Cores: 12
14:01:55.162: Physical Memory: 65536MB Total
14:01:55.162: OS Name: macOS
14:01:55.162: OS Version: Version 13.4.1 (Build 22F82)
14:01:55.162: Rosetta translation used: false
14:01:55.162: Kernel Version: 22.5.0
14:01:55.163: hotkeys-cocoa: Using layout 'com.apple.keylayout.US'
14:01:55.163: Current Date/Time: 2023-09-19, 14:01:55
14:01:55.163: Browser Hardware Acceleration: true
14:01:55.163: Qt Version: 6.4.3 (runtime), 6.4.3 (compiled)
14:01:55.163: Portable mode: false
14:01:55.323: OBS 29.1.3 (mac)
14:01:55.323: ---------------------------------
14:01:55.324: ---------------------------------
14:01:55.324: audio settings reset:
14:01:55.324: samples per sec: 48000
14:01:55.324: speakers: 2
14:01:55.324: max buffering: 960 milliseconds
14:01:55.324: buffering type: dynamically increasing
14:01:55.325: ---------------------------------
14:01:55.325: Initializing OpenGL...
14:01:55.380: Loading up OpenGL on adapter ATI Technologies Inc. AMD Radeon Pro 5300M OpenGL Engine
14:01:55.380: OpenGL loaded successfully, version 4.1 ATI-4.12.7, shading language 4.10
14:01:55.729: ---------------------------------
14:01:55.729: video settings reset:
14:01:55.729: base resolution: 1280x720
14:01:55.729: output resolution: 1280x720
14:01:55.729: downscale filter: Bicubic
14:01:55.729: fps: 60/1
14:01:55.729: format: NV12
14:01:55.729: YUV mode: Rec. 709/Partial
14:01:55.729: NV12 texture support not available
14:01:55.729: P010 texture support not available
14:01:55.730: Audio monitoring device:
14:01:55.730: name: Default
14:01:55.730: id: default
14:01:55.730: ---------------------------------
14:01:55.737: No AJA devices found, skipping loading AJA UI plugin
14:01:55.737: Failed to initialize module 'aja-output-ui'
14:01:55.743: No AJA devices found, skipping loading AJA plugin
14:01:55.743: Failed to initialize module 'aja'
14:01:55.744: Failed to load 'en-US' text for module: 'decklink-captions'
14:01:55.746: Failed to load 'en-US' text for module: 'decklink-output-ui'
14:01:55.747: A DeckLink iterator could not be created. The DeckLink drivers may not be installed
14:01:55.747: Failed to initialize module 'decklink'
14:01:55.900: [obs-browser]: Version 2.21.1
14:01:55.900: [obs-browser]: CEF Version 103.0.5060.134 (runtime), 103.61.23+g2fe5a76+chromium-103.0.5060.134 (compiled)
14:01:55.914: [obs-websocket] [obs_module_load] you can haz websockets (Version: 5.2.3 | RPC Version: 1)
14:01:55.914: [obs-websocket] [obs_module_load] Qt version (compile-time): 6.4.3 | Qt version (run-time): 6.4.3
14:01:55.914: [obs-websocket] [obs_module_load] Linked ASIO Version: 101201
14:01:55.919: [obs-websocket] [obs_module_load] Module loaded.
14:01:55.924: os_dlopen(/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib->/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib): dlopen(/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib, 0x0101): tried: '/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib' (no such file), '/Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib' (no such file)
14:01:55.924:
14:01:55.924: [vlc-video]: Couldn't find VLC installation, VLC video source disabled
14:01:55.943: <StreamDeck> Plugin version 5.5.1.1
14:01:55.944: <StreamDeck> [Server] Listening on '127.0.0.1:28186'.
14:01:55.945: [Move Transition] loaded version 2.9.5
14:01:55.945: os_dlopen(/Library/Application Support/obs-studio/plugins/StreamDeckPlugin/bin/StreamDeckPlugin.so->/Library/Application Support/obs-studio/plugins/StreamDeckPlugin/bin/StreamDeckPlugin.so): dlopen(/Library/Application Support/obs-studio/plugins/StreamDeckPlugin/bin/StreamDeckPlugin.so, 0x0101): Library not loaded: @executable_path/../Frameworks/libobs.0.dylib
14:01:55.945: Referenced from: <A42B2188-AEC4-3E1F-9569-681E98538F48> /Library/Application Support/obs-studio/plugins/StreamDeckPlugin/bin/StreamDeckPlugin.so
14:01:55.945: Reason: tried: '/Applications/OBS.app/Contents/Frameworks/libobs.0.dylib' (no such file), '/usr/lib/libobs.0.dylib' (no such file, not in dyld cache)
14:01:55.945:
14:01:55.945: Module '/Library/Application Support/obs-studio/plugins/StreamDeckPlugin/bin/StreamDeckPlugin.so' not loaded
14:01:55.946: ---------------------------------
14:01:55.946: Loaded Modules:
14:01:55.946: move-transition
14:01:55.946: StreamDeckPlugin
14:01:55.946: vlc-video
14:01:55.946: text-freetype2
14:01:55.946: rtmp-services
14:01:55.946: obs-x264
14:01:55.946: obs-websocket
14:01:55.946: obs-vst
14:01:55.946: obs-transitions
14:01:55.946: obs-outputs
14:01:55.946: obs-filters
14:01:55.946: obs-ffmpeg
14:01:55.946: obs-browser
14:01:55.946: mac-virtualcam
14:01:55.946: mac-videotoolbox
14:01:55.946: mac-syphon
14:01:55.946: mac-capture
14:01:55.946: mac-avcapture
14:01:55.946: image-source
14:01:55.946: frontend-tools
14:01:55.946: decklink-output-ui
14:01:55.946: decklink-captions
14:01:55.946: coreaudio-encoder
14:01:55.946: ---------------------------------
14:01:55.946: [obs-websocket] [obs_module_post_load] Post load started.
14:01:55.946: [obs-websocket] [obs_module_post_load] obs-websocket plugin API version: 2
14:01:55.946: [obs-websocket] [obs_module_post_load] Called GetVersion. Status Code: 100 | Comment: (null) | Response Data: {"availableRequests":["GetMonitorList","OpenInputInteractDialog","SetMediaInputCursor","ToggleRecordPause","StopRecord","ToggleRecord","GetRecordStatus","SendStreamCaption","TriggerMediaInputAction","StopStream","StartStream","SetOutputSettings","GetOutputSettings","StartOutput","ToggleOutput","SaveReplayBuffer","StopReplayBuffer","StartReplayBuffer","StopVirtualCam","StartVirtualCam","SetSceneItemPrivateSettings","GetStudioModeEnabled","GetSceneItemPrivateSettings","SetSceneItemBlendMode","GetSourceFilterDefaultSettings","SetSceneItemLocked","GetLastReplayBufferReplay","GetSceneItemBlendMode","GetSceneItemTransform","GetGroupSceneItemList","GetSceneItemId","ToggleVirtualCam","GetSceneItemList","GetInputList","GetVideoSettings","DuplicateSceneItem","GetSourcePrivateSettings","GetSourceScreenshot","SetSourceFilterIndex","RemoveScene","GetSceneItemIndex","SetTBarPosition","GetSourceFilter","OpenInputFiltersDialog","SetSourceFilterName","RemoveSourceFilter","GetSourceFilterList","GetMediaInputStatus","TriggerStudioModeTransition","GetCurrentSceneTransitionCursor","SetCurrentSceneTransitionDuration","OffsetMediaInputCursor","GetVirtualCamStatus","CreateSourceFilter","SetCurrentSceneTransition","GetTransitionKindList","SetSceneItemEnabled","SetSceneItemIndex","SetInputAudioTracks","GetInputVolume","GetInputAudioTracks","SetCurrentProgramScene","SetInputAudioMonitorType","SetInputAudioSyncOffset","SetInputAudioBalance","GetCurrentSceneTransition","SetInputSettings","SetSourceFilterEnabled","GetInputSettings","OpenSourceProjector","SetSceneItemTransform","GetInputAudioBalance","BroadcastCustomEvent","GetPersistentData","SetInputName","GetInputKindList","CreateSceneCollection","GetOutputStatus","GetSceneSceneTransitionOverride","SetInputMute","SetCurrentSceneTransitionSettings","GetSceneTransitionList","PauseRecord","SetSceneSceneTransitionOverride","OpenVideoMixProjector","SetCurrentPreviewScene","SetSceneName","CreateScene","GetInputAudioSyncOffset","GetStreamStatus","GetGroupList","GetOutputList","GetSceneList","CreateSceneItem","GetInputMute","GetCurrentProgramScene","SetSourceFilterSettings","CallVendorRequest","SetStreamServiceSettings","SaveSourceScreenshot","GetRecordDirectory","GetInputDefaultSettings","GetStreamServiceSettings","CreateProfile","RemoveProfile","ResumeRecord","GetInputAudioMonitorType","RemoveInput","OpenInputPropertiesDialog","ToggleReplayBuffer","GetHotkeyList","SetCurrentSceneCollection","GetSceneItemLocked","GetSceneCollectionList","GetProfileList","ToggleInputMute","TriggerHotkeyByKeySequence","CreateInput","GetCurrentPreviewScene","TriggerHotkeyByName","SetStudioModeEnabled","GetSourceActive","SetVideoSettings","PressInputPropertiesButton","SetProfileParameter","SetInputVolume","ToggleStream","SetSourcePrivateSettings","Sleep","StartRecord","GetReplayBufferStatus","SetPersistentData","GetProfileParameter","GetInputPropertiesListPropertyItems","GetSpecialInputs","GetStats","RemoveSceneItem","StopOutput","SetCurrentProfile","GetVersion","GetSceneItemEnabled"],"obsVersion":"29.1.3","obsWebSocketVersion":"5.2.3","platform":"macos","platformDescription":"macOS 13.4","rpcVersion":1,"supportedImageFormats":["bmp","cur","heic","heif","icns","ico","jp2","jpeg","jpg","pbm","pgm","png","ppm","tif","tiff","wbmp","webp","xbm","xpm"]}
14:01:55.946: [obs-websocket] [obs_module_post_load] Post load completed.
14:01:55.962: obs_register_encoder: Encoder id 'com.apple.videotoolbox.videoencoder.h264.gva' already exists! Duplicate library?
14:01:55.962: obs_register_encoder: Encoder id 'com.apple.videotoolbox.videoencoder.hevc.gva' already exists! Duplicate library?
14:01:55.962: [VideoToolbox encoder]: Added VideoToolbox encoders
14:01:55.962: ==== Startup complete ===============================================
14:01:56.008: All scene data cleared
14:01:56.008: ------------------------------------------------
14:01:57.103: coreaudio: Device 'BlackHole 16ch' [48000 Hz] initialized
14:01:57.104: [Loaded global audio device]: 'Desktop Audio'
14:01:57.174: coreaudio: Device 'USB Audio Device' [48000 Hz] initialized
14:01:57.175: [Loaded global audio device]: 'Mic/Aux'
14:01:57.202: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: Mic/Aux)
14:01:57.202:
14:01:57.315: Logitech c920: Selected device 'HD Pro Webcam C920'
14:01:57.318: Logitech c920: Using preset High
14:01:57.958: Switched to scene '1 Office C920'
14:01:57.958: ------------------------------------------------
14:01:57.958: Loaded scenes:
14:01:57.958: - scene '1 Office C920':
14:01:57.958: - source: 'Interview Background' (image_source)
14:01:57.958: - source: 'Logitech c920' (av_capture_input_v2)
14:01:57.958: ------------------------------------------------
 

sebastianbeckmann

New Member
@oracle22 could you check if the plugin is installed in "~/Library/Application Support/obs-studio/plugins"? If not, is there one in "/Library/Application Support/obs-studio/plugins"? (The tilde (~) makes a difference)
 

uuoocl

Member

Lower Mask Delay​

The MacOS Background Removal Plug-in has a small mask delay. Using a combination of Plug-ins, the mask delay can be lowered even more.

Required OBS Plugins​

First, install these plug-ins

Create a Scene​

After installing the required plug-ins create a new scene. An example scene name "BGR_Scene".

Add Sources to the Scene​

  1. Add a Video Capture Device Source (Set to not visible)
  2. Add a Source Clone(Set to not visible)
    • Settings: Clone type = Source
      • Clone = Video Capture Device
  3. Add a Source Clone
    • Settings: Clone type = Source
      • Clone = Video Capture Device
    • The second Source Clone will be named "Source Clone 2" by default
A picture of Scene and Source names

Add Filters​

  1. Select “Source Clone”
    • Add a “macOS Background Removal” filter
      • Settings: Threshold = .8, Quality= Balanced
  2. Select “Source Clone 2”
    • Add a “Render Delay” filter
      • Settings: Delay = 90ms
    • Add a "Advanced Mask” filter
      • Settings:
        • Mask Effect = Alpha Mask
        • Mask Type = Source
        • Source: Source Clone
NOTE: This guide was tested on a MacBook Pro M1. Settings may vary on a different Mac.
 
Great plugin - appreciate that the Mac universe is getting some love.

So I had a thought about how to make this plugin more effective with cleaner removal/separation, and was wondering if anyone smarter than me could chime in and tell me if this makes any sense and if it would actually work or help at all....

I have no idea how any of this actually works, but I assume it's comparing foreground pixels with background ones, and then determining what is and is not the foreground element and then removing the background. Most, if not all, streaming setups are usually a static shot, and the background is more or less the same (not accounting for lighting changes) - Would it be possible to use a clean still image of the background without the foreground element you need removed in it as a reference so that the vision api knows exactly what the background is, and would that in any way improve the quality of the separation? It makes sense in my brain, but someone please school me!
 

BBDUZZI

New Member
I'm having difficulty installing background removal on my Mac.
I already downloaded the .pkg file, but it doesn't work, what should I do?
 

lcalder

Member
Great plugin - appreciate that the Mac universe is getting some love.

So I had a thought about how to make this plugin more effective with cleaner removal/separation, and was wondering if anyone smarter than me could chime in and tell me if this makes any sense and if it would actually work or help at all....

I have no idea how any of this actually works, but I assume it's comparing foreground pixels with background ones, and then determining what is and is not the foreground element and then removing the background. Most, if not all, streaming setups are usually a static shot, and the background is more or less the same (not accounting for lighting changes) - Would it be possible to use a clean still image of the background without the foreground element you need removed in it as a reference so that the vision api knows exactly what the background is, and would that in any way improve the quality of the separation? It makes sense in my brain, but someone please school me!
Interesting thought. I've no idea whether it would make sense programming-wise, but I can think of situations where I want it to isolate MY IMAGE, but if my cat or child walks by in the background, or if there's a multicolor object in the background, that it wouldn't even bother considering those things for visibility. It might prove cumbersome in practice if your clothing colors/style change from session to session, requiring a new still image to be taken from time to time or for each session...
 
Top