If you're tired of dealing with DroidCam's WiFi-only limitations or want a more reliable USB connection for streaming, this guide will show you how to transform your Android phone into a high-quality virtual webcam for OBS Studio on Linux systems like Pop!_OS.
Why This Method Works Better
After struggling with DroidCam's WiFi connectivity issues, I discovered this USB-based approach that delivers near-zero latency and crisp video quality. While you'll need a separate microphone for audio (or can set up PulseAudio loopback), the video quality improvement is worth it.
example:
in OBS:
This solution creates a proper virtual webcam device (/dev/videoX
) that OBS and other applications can recognize as a standard camera input.
The Technical Stack
Our setup uses three key components working together:
scrcpy - Originally designed for Android screen mirroring and remote control, we're repurposing it to stream your phone's camera feed over USB with minimal latency.
v4l2loopback - This kernel module creates a virtual video device that acts as a bridge between scrcpy's output and OBS's input expectations.
ffmpeg - While optional, it helps with video format conversion when needed.
Installation and Setup
Installing Required Packages
Start by updating your system and installing the necessary tools:
sudo apt update
sudo apt install scrcpy v4l2loopback-dkms ffmpeg
Setting Up the Virtual Camera Device
Load the v4l2loopback kernel module to create your virtual webcam:
sudo modprobe v4l2loopback
To make this persistent across reboots, add it to your modules list:
echo "v4l2loopback" | sudo tee -a /etc/modules
Preparing Your Android Device
Enable USB debugging on your Android phone by following these steps:
- Navigate to Settings → About Phone
- Tap "Build Number" seven times to unlock Developer Options
- Go to Developer Options and enable USB Debugging
- Connect your phone via USB cable
- Allow debugging access when prompted on your phone
Starting the Camera Stream
Launch scrcpy with virtual webcam output using this command:
scrcpy --v4l2-sink=/dev/video2
This redirects your phone's display (including camera apps) to the virtual webcam device at /dev/video2
.
Configuring OBS Studio
In OBS Studio:
- Click the "+" button in Sources
- Select "Video Capture Device" or "Window Capture"
- Name your source (e.g., "Android Camera")
- Choose
/dev/video2
as the device - Adjust resolution and frame rate settings as needed
If your video appears rotated, add the rotation parameter:
scrcpy --v4l2-sink=/dev/video2 --rotation=1
Troubleshooting Common Issues
Virtual Device Not Found
If /dev/video2
doesn't appear, verify the module loaded correctly:
ls /dev/video*
If missing, reload the v4l2loopback module:
sudo modprobe -r v4l2loopback && sudo modprobe v4l2loopback
Black Screen in OBS
Try limiting the resolution to improve compatibility:
scrcpy --v4l2-sink=/dev/video2 --max-size=1024
Make sure to restart OBS after launching scrcpy.
Phone Connection Issues
Check if your device is properly connected:
adb devices
If your phone isn't listed, reconnect the USB cable and re-enable USB debugging.
Streamlining Your Workflow
Create a simple script to avoid typing the full command each time:
nano ~/android_cam.sh
Add this content:
#!/bin/bash
scrcpy --v4l2-sink=/dev/video2 --max-size=1024
Make it executable:
chmod +x ~/android_cam.sh
Now you can start your Android webcam with:
~/android_cam.sh
Final Thoughts
This method provides a reliable, low-latency solution for using your Android phone as a webcam without relying on potentially unstable WiFi connections. The USB connection ensures consistent performance, making it ideal for important streams or recordings where reliability matters most.
The setup works with any camera app on your phone, giving you flexibility in how you want to frame and control your video feed. Just remember to keep your phone charged or use a longer USB cable that supports both data and charging if you plan on extended recording sessions.
Top comments (0)