Skip to content

No webcam? No problem

Penguins on grass

We don't all have a working webcam and purchasing one to use occasionally is not always a wise decision.

If you've got an Android 12+ device with a built-in camera and a PC/laptop running Linux, you're all set! scrcpy (pronounced screen copy) enables the mirroring of an Android device's camera as a webcam, among other features.

Note: this article is based on scrcpy v3.1.

Install scrcpy

To get started, follow these instructions to install scrcpy on your system.

Install Video4Linux

Install v4l2loopback-dkms and v4l-utils on your system so that your Android device can send the video stream to a virtual v4l2 loopback device, i.e. a virtual webcam. You can find the installation steps for your Linux distro online.

Create a virtual video device

Create a virtual video device to stream your Android device camera's feed to:

sudo modprobe v4l2loopback

List video devices

List all video devices on your system to check whether the virtual video device has been created (the following command should output /dev/videoN, where N is an integer):

v4l2-ctl --list-devices

Enable USB debugging

Enable USB debugging on your Android device.

Connect Android device

Connect your Android device to your PC/laptop, preferably via USB.

Stream video

For the sake of simplicity, let's say your virtual video device is /dev/video0 and your Android device camera's resolution is 1920x1080. Stream your camera feed (if a window pops up on your Android device, prompting you to allow USB debugging, allow it):

scrcpy --v4l2-sink=/dev/video0 --video-source=camera --camera-facing=front --no-audio --camera-size=1920x1080 --orientation=flip0

Detach the virtual video device

You can delete the virtual video device after you've disconnected your Android device from your PC/laptop:

sudo modprobe v4l2loopback -r

Use in web browser

One caveat about using the virtual webcam in web browsers, e.g. on Google meet, is to make sure to stream the video from your Android device first then open the web browser. Otherwise, there's a possibility that the virtual device is not detected.

References

This article was inspired by Abish Vijayan's article.