Skip to content

Webcam

Using your android phone as webcam

I wanted to use my android phone as a webcam for my pc and it worked really well.
I've used Scrcpy and the v4l2loopback kernel module to provide a virtual cam for discord and other applications.

I've tested this on Archlinux with an Samsung A21S with a custom android 16 rom.

To get started, first install the following: (Replace linux-headers if you're using not the default arch kernel. More here)

sudo pacman -S v4l2loopback-dkms linux-headers scrcpy android-tools

Then load the kernel module to create a viritual camera device: (The label will show up as camera info in eg. discord)

sudo modprobe v4l2loopback exclusive_caps=1 card_label="Android-Webcam"

Now you have a virtual camera. Now we will use the phone as camera.
First of all, Very important! You need to enable developer options on your phone.S

And also run the following command to list all video devices:

v4l2-ctl --list-devices

You need to remember the video device to use in later commands! Possible output might be:

Android-Webcam (platform:v4l2loopback-000):
    /dev/video2

Integrated Camera: Integrated C (usb-0000:00:14.0-8):
    /dev/video0
    /dev/video1
    /dev/media0

So I need to remember /dev/video2

Wired

To use your phone as usb cam, enable Usb Debugging in the developer settings. Plug your phone into your computer using a usb cable and use the following command to activate the camera streaming:

scrcpy --video-source=camera --camera-size=1920x1080 --v4l2-sink=<the path of your virtual video device> -N

In my example I'm using a camera resolution of 1920x1080 but you can change this however you want. There should appear a popup on your phone to allow the wired connection to use debugging. You need to allow usb debugging.
You may need to run the the command again.
Now your android camera should directly stream to your virtual camera device.

Wireless

To use your phone as wireless wifi cam, enable Wifi Debugging in the developer settings. To use your phone camera using wifi connection, you need to first connect your phone to your computer using a usb cable and run the following command:

adb tcpip 5555
Now unplug your phone find out the ip address(ipV4 address eg. "192.168.171.4"). You can check it in the system information tab in the settings.
Now connect your phone via adb:
adb connect <your phones ip>:5555

You may need to accept a popup on your phone. Now start the video stream with Scrcpy and your desired resolution. I'm using 1920x1080 but you can change this however you want.

scrcpy --video-source=camera --camera-size=1920x1080 --v4l2-sink=<the path of your virtual video device> -N

Now your android camera should directly stream to your virtual camera device.