DEV Community

Cover image for USE SPARE ANDROID PHONE AS WEBCAM FOR YOUR PC.
Kwaku Duah
Kwaku Duah

Posted on Edited on

USE SPARE ANDROID PHONE AS WEBCAM FOR YOUR PC.

🔧 Turn Your Spare Android Phone into a Webcam for Linux!

Ever had that awkward moment when you're all set for a video interview on your PC—only to find out your webcam quality is atrocious?

Breathe easy. You can turn that spare Android phone lying around into a high-quality webcam for your Linux PC!

Chances are, that old phone has a camera that's leagues better than your laptop's built-in one. Since webcams are pricey, this budget-friendly guide has you covered.


✅ What You Need:

  • An Android Phone
  • USB Cable
  • A Linux PC

This is a beginner-friendly tutorial. Just follow along step-by-step, and you’ll be ready to roll.


📚 Table of Contents:

  1. Prepare the Android Phone
  2. Install Dependencies on the PC
  3. Configure the Phone with the PC
  4. Launch the Phone’s Camera as Webcam
  5. Conclusion

🛠️ Prepare the Android Phone

Android runs on the Linux kernel. A few tweaks and we’re good to go.

  1. Go to Settings > About Phone
  2. Tap Build Number 7 times to activate Developer Mode
  3. Go back, open Developer Options
  4. Toggle on USB Debugging
  5. Connect your phone via USB to your Linux PC

📦 Install Dependencies on the PC

  1. Open a terminal and run:
sudo apt install android-tools-adb -y
adb devices
Enter fullscreen mode Exit fullscreen mode

Your Android phone will ask to allow USB debugging. Accept it.

🔹 ADB stands for Android Debug Bridge.

  1. Install scrcpy (Screen Copy tool):
sudo apt install scrcpy
Enter fullscreen mode Exit fullscreen mode

Then launch:

scrcpy
Enter fullscreen mode Exit fullscreen mode

This mirrors your phone screen to the PC.


⚙️ Configure the Camera with PC

  1. Install ffmpeg:
sudo apt install ffmpeg -y
Enter fullscreen mode Exit fullscreen mode
  1. Clone and install v4l2loopback to create a virtual camera:
git clone https://github.com/umlaeute/v4l2loopback
cd v4l2loopback
make && sudo make install
sudo depmod -a
sudo modprobe v4l2loopback
Enter fullscreen mode Exit fullscreen mode

📲 Setting Up the Android Camera

  1. Install IP Webcam from the Play Store.

    Note: The free version has ads. Consider going premium for a smoother experience.

  2. Open the app and scroll down to tap Start Server

  3. You'll see an IPv4 address at the bottom (e.g., http://192.168.x.x:8080)


🔄 Port Forwarding via ADB

  1. List devices:
adb devices -l
Enter fullscreen mode Exit fullscreen mode

Output:

List of devices attached
affhh41a device usb: product:phone brand device transport_id:2
Enter fullscreen mode Exit fullscreen mode
  1. Export the device ID:
export ANDROID_SERIAL=affhh41a
Enter fullscreen mode Exit fullscreen mode
  1. Forward the port:
adb forward tcp:8080 tcp:8080
Enter fullscreen mode Exit fullscreen mode

Now visit:

  • http://localhost:8080 – full IP Webcam interface
  • http://localhost:8080/video – direct video stream (use Firefox only)

IP Webcam Interface


🎥 Create a Virtual Webcam

  1. Run this to create the virtual webcam:
sudo modprobe v4l2loopback
Enter fullscreen mode Exit fullscreen mode
  1. List available devices:
v4l2-ctl --list-devices
Enter fullscreen mode Exit fullscreen mode

Your new virtual webcam is likely /dev/video2.


🚀 Redirect the Video Stream

Use ffmpeg to pipe the stream to your virtual webcam:

sudo ffmpeg -i http://localhost:8080/video -vf format=yuv420p -f v4l2 /dev/video2
Enter fullscreen mode Exit fullscreen mode

Now, applications like Google Meet, Zoom, OBS, or OpenCV can use your phone as a webcam 🎉


🎬 Webcam in Google Meet (via Firefox):

Google Meet using virtual webcam


🔴 OBS Studio Preview:

OBS Studio Virtual Camera


✅ Conclusion

While there isn’t a GUI to handle all this, the command-line workflow with tools like scrcpy, adb, and ffmpeg makes it totally doable—even for beginners.

Questions? Suggestions? Drop them in the comments—your feedback is golden!

Top comments (0)