It's not a surprise that webcams are in demand right now. I recently came in need of one, since I started tutoring online again. Searching around to buy a Logitech C270, I came to realize that the prices have more than doubled for a webcam that is quite old actually.

I was pretty irritated and hesitant to spend around 50€ for a webcam, so I started exploring other solutions. I have around an old Motorola E2 android phone. I already use it as a tethering device (among other things) and thought that it would quite nice to use this as a webcam. Meet DroidCam! It's a (sadly proprietary) android application that can serve the video feed from your phone as a webcam feed to your computer.

The installation process is pretty straight forward, get the apk somewhere to install on your phone and then follow the instructions here to install the program and drivers for your (gnu/linux) computer. This will then register the android camera as v4l2loopback device, that will work as proper webcam for most applications - I haven't encountered any problems, using jitsi both natively and the web app and obs studio.

However the fact that I had to reach my mobile in order to enable the webcam was a bit boring so I decided to write a simple script to enable and disable it. In order to do so, it is needed to have installed and configured adb as well as the psutil python library and of course a python interpreter. If you try to use it don't forget to set your passkey and also define the preferred connection method (check out the droidcam documentation).

So here is the script:

#!/usr/bin/env python
from subprocess import call
from time import sleep
import psutil

port = "4747"
package = "com.dev47apps.droidcam"
connection = "adb" #pass the ip here if you want a network connection
unlock_passkey = "****"
# keycodes for android
key_power = "26"
key_menu = "82"
key_enter = "66"

def checkDroidCam():
    for proc in psutil.process_iter():
            if 'droidcam' in
                return True
        except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
    return False    

def enableWebCam():
    # unlock the phone
    call(["adb", "shell", "input", "keyevent", key_power])
    call(["adb", "shell", "input", "keyevent", key_menu])
    call(["adb", "shell", "input", "text", unlock_passkey])
    call(["adb", "shell", "input", "keyevent", key_enter])

    # start the android application
    call(["adb", "shell", "monkey", "-p", package, "1"])

    # connect
    call(["droidcam-cli", connection, port])

def disableWebCam():
    call(["killall", "droidcam-cli"])
    call(["adb", "shell", "am", "force-stop", package])
    call(["adb", "shell", "input", "keyevent", key_power])

def main():    
    if checkDroidCam():

if __name__ == "__main__":

Nothing special for sure, but it's a nice feature to have given that now I can mount it on my desk in a nice angle and never have to move the phone again. By running the script with a keybinding I can have the laptop feeling of enabling my webcam and also cleanly exit from droidcam when not needed anymore.

Even if you don't have an old phone around you can buy one for quite cheap and use it as webcam, along with using it as a Piratebox, server or any other usage that a tiny computer may have. To be honest this sounds a much better investement that the prices that webcams have reached right now. And for the range of money the image is much better as well!

📷 📷 📷