惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
C
Check Point Blog
S
SegmentFault 最新的问题
腾讯CDC
IT之家
IT之家
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
博客园 - Franky
V
Visual Studio Blog
The Register - Security
The Register - Security
GbyAI
GbyAI
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
T
Troy Hunt's Blog
小众软件
小众软件
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
C
CERT Recently Published Vulnerability Notes
aimingoo的专栏
aimingoo的专栏
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
G
GRAHAM CLULEY
T
Tenable Blog
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
H
Help Net Security
WordPress大学
WordPress大学
The Cloudflare Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
W
WeLiveSecurity
I
InfoQ
P
Privacy International News Feed

Homepage on Aditya Telange

One Year with evil-winrm-py - A Retrospective Bypassing LinkedIn's Connection Privacy with a Simple Search Filter Making Dynamic Instrumentation Accessible with Frida UI Breaking Payload Encryption in Web Applications HackTheBox (HTB) - Escape HackTheBox (HTB) - Resolute HackTheBox (HTB) - Certified State of VMWare Workstation (Pro?) on Linux Android App Security Testing Lab with MobSleuth Breaking down Reverse shell commands HackTheBox (HTB) - Photobomb Merging AOSP Security Patches into Custom ROMs Primer on HTTP Security Headers Image Zoom-In effect with HUGO HackTheBox (HTB) - Legacy HackTheBox (HTB) - Lame Cryptohack - Keyed Permutations [5 pts] Cryptohack - Resisting Bruteforce [10 pts] Cryptohack - RSA Starter 1 [10 pts] Cryptohack - Base64 [10 pts] Cryptohack - Bytes and Big Integers [10 pts] Cryptohack - Hex [5 pts] Cryptohack- XOR Starter [10 pts] HackTheBox (HTB) - Horizontall HackTheBox (HTB) - Forge HackTheBox (HTB) - Previse HackTheBox (HTB) - BountyHunter HackTheBox (HTB) - Explore HackTheBox (HTB) - Cap HackTheBox (HTB) - Pit HackTheBox (HTB) - Knife HackTheBox (HTB) - Love HackTheBox (HTB) - Tenet HackTheBox (HTB) - Ready Watermarking images with HUGO My Github Project went viral! Cryptohack - ASCII [5 pts] Cryptohack - Finding Flags [2 pts] Cryptohack - Great Snakes [3 pts] Cryptohack - JWT Sessions [10 pts] Cryptohack - Network Attacks [5 pts] Cryptohack - Token Appreciation [5 pts] CAF's Android for MSM Basic Website Analytics with Vercel Github Actions as Temporary File Sharing Platform Addition of prebuilt APK - AOSP Rom Development External Link With target='_blank' in Hugo Markdown Setting Up Build Environment - AOSP Rom Development Getting Started - AOSP Rom Development Using Secure HTTP Headers with Vercel/Zeit Education and Certifications Link Tree ↟ | Aditya Telange Personal Projects Resume - Aditya Telange Security Acknowledgements About Me Graph View License Privacy Policy
Android phone as a Webcam on Linux
[Aditya Telange](https://x.com/adityatelange) · 2024-02-17 · via Homepage on Aditya Telange

In this guide, we’ll learn how to create a virtual webcam on a Linux device using an Android device’s camera. We’ll go through the installation of key packages like adb, v4l2loopback, and scrcpy, allowing us to utilize an Android device’s camera as a virtual webcam.

Pre-requisites

  • An Android phone (Android 12+)
  • Linux Desktop (scoping to any Debian-based distro for this guide)

Installing required packages

1. adb

adb, which stands for Android Debug Bridge, is a versatile command-line tool used for communicating with Android devices directly from your computer. 1

2. v4l2loopback

v4l2loopback is a kernel module (software program) for Linux that allows you to create virtual video devices. 2

$ sudo apt install v4l2loopback-dkms

Load the kernel module, setting the exclusive_caps option to 1, and label it as “Virtual Webcam.”

Note: Setting exclusive_caps to 1 is important for Chromium/WebRTC-based tools like Google Meet or Zoom, which requires a webcam device with only capture capabilities

# Load the `v4l2loopback` kernel module
# and set `exclusive_caps` option to `1`
# (important for Chromium/WebRTC-based tools like Google Meet or Zoom,
# which require a webcam device with only capture capabilities)
$ sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam"

Verify the creation of the virtual webcam device:

$ v4l2-ctl --list-devices    # or you may `ls /dev/video*`
Dummy video device (0x0000) (platform:v4l2loopback-000):
  /dev/video0

3. scrcpy

scrcpy stands for “screen copy” and is a free and open-source tool that allows you to mirror and control your Android device from your computer. It works on Linux, Windows, and macOS, making it a cross-platform solution. 3

# Install pre-requisites for Debian/Ubuntu
sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
                 gcc git pkg-config meson ninja-build libsdl2-dev \
                 libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
                 libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
$ git clone --depth 1 --branch v2.3.1 https://github.com/Genymobile/scrcpy
$ cd scrcpy
$ ./install_release.sh  # may ask for your sudo password

Connecting your phone via with adb

  • Enable Developer options using this guide from developer.android.com
  • Enable USB debugging using this guide from developer.android.com
  • Connect your Android phone to your Linux computer.
  • When prompted on your Android device, click on ALLOW to grant USB debugging access.
  • Verify that your device is detected (device ID may vary):
    $ adb devices
    List of devices attached
    978a27c9  device
    

Using scrcpy

Now that our device is connected properly we can list the cameras 4 we can utilize:

Example output:

scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  978a27c9                        device  DEVICEX
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 0.6 MB/s (66007 bytes in 0.100s)
[server] INFO: Device: [make] make DEVICEX (Android 12)
[server] INFO: List of cameras:
    --camera-id=0    (back, 4608x3456, fps=[10, 15, 28, 30])
    --camera-id=1    (front, 3264x2448, fps=[15, 30])
    --camera-id=2    (back, 3264x2448, fps=[15, 28, 30])
    --camera-id=3    (back, 1600x1200, fps=[15, 30])
    --camera-id=4    (back, 1600x1200, fps=[15, 27])
    --camera-id=5    (back, 4608x3456, fps=[10, 15, 28, 30])
    --camera-id=6    (back, 4608x3456, fps=[10, 15, 28, 30])

Start scrcpy with the desired camera source and output to the virtual webcam device:

$ scrcpy --video-source=camera --no-audio --camera-facing=front \
    --v4l2-sink=/dev/video0
  • v4l2-sink outputs the received video stream into v4l2 device /dev/video0, which we had created earlier.
  • You may check more available options here scrcpy - camera mirroring

Example output:

scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
INFO: Camera video source: control disabled
INFO: ADB device found:
INFO:     -->   (usb)  978a27c9                        device  DEVICEX
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 6.9 MB/s (66007 bytes in 0.009s)
[server] INFO: Device: [make] make DEVICEX (Android 12)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.3.2-blah-blah
INFO: Trilinear filtering enabled
[server] INFO: Using camera '1'
INFO: v4l2 sink started to device: /dev/video0
INFO: Texture: 3264x2448
# A new window will pop up which will serve as a viewfinder.

We can now use our newly added Virtual Webcam for video calls and conferences. 🎉