Skip to content

Instantly share code, notes, and snippets.

@ismith
Last active March 12, 2020 03:20
Show Gist options
  • Save ismith/4218fb6726864b14f9990b6eb23cd07b to your computer and use it in GitHub Desktop.
Save ismith/4218fb6726864b14f9990b6eb23cd07b to your computer and use it in GitHub Desktop.

This is extremely Linux only due to the dependency on v4l2loopback and obs-v4l2sink, though, as mentioned below, CatxFish has also written a similar plugin for Windows. I have not tried it, YMMV.

What is this?

Wanna composite your face (as a video, from your webcam), on top of a video of your choosing, and use that for your conference calls? NOW YOU CAN! (Zoom only supports still-image virtual backgrounds. BOO.)

Note: you will need a greenscreen for this. (You can try all the software-y bits below without one, but it won't look very good at all.) $60 on Amazon, you can probably find one cheaper. (Or make. Or, honestly, it might work if you have a solid-colored wall behind you, which I do not.)

Dependencies

WTF?

OBS Studio is a ... I guess it's intended for streamers and video production? Then obs-v4l2sink is an OBS Studio plugin (the same author made a Windows equivalent too) that lets OBS Studio send output to a fake video device that apps will see as a webcam. Like Zoom, for instance. It depends on v4l2loopback, a kernel module.

HOW TO

Modprobe

After installing the dependencies, first:

  • sudo modprobe v4l2loopback exclusive_caps=1 (I am not certain if exclusive_caps=1 is necessary, but it WFM)

OBS Studio composition

  • On the bottom of the obs-studio window, one of the boxes is "Sources". Click the plus; you want two sources.
    • One, "Video Capture Device (V4L2)" is your webcam.
    • The other is "Media Source" - this is the video file you want playing behind you. You probably want to check "loop".
  • In the Sources list, right click the Video Capture Dev source; add an Effects Filter, "Chroma Key"
  • Other relevant actions in the Sources list:
    • The eyeball icon will show/hide a layer - this is akin to Photoshop's layers
    • Right click has menu items Transform -> {Fit,Stretch} to Screen
    • Right click has menu items Order -> Move to {Top,Bottom,Front,Back} - again, this is akin to Photoshop's layers, and is how you decide which is on top

OBS Studio send to fake webcam

Menu: Tools -> V4L2 Video Output. "Path to V4L2 Device" is most likel /dev/video1. For me, Video Format YUY2 worked; the others may or may not be available, I honestly don't know what the difference is.

Click Start. (There"s an "Auto Start" checkbox, dunno what it's for.)

Zoom

Now open Zoom. You can test this in settings, or you can click the up arrow next to "Start Video" (or "Stop Video") and select your new video source - it'll be "Dummy video device 0x0000" (or 1, 2, etc).

Now go surprise your colleagues, who will be very jealous that they only have a static virtual background.

Contributing

If you find that this doesn't quite work and have a tweak to fix it, or can explain the things I mentioned I don't understand, please let me know and I'll update this file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment