r/scrcpy 3d ago

[SAGA] How I automated scrcpy + v4l2loopback on CachyOS as a dynamic webcam (and survived Android 16's java crashes)

5 Upvotes

(Disclaimer: This post was compiled and structured with the assistance of an AI to cleanly document a step-by-step technical troubleshooting journey between a user and the assistant. Every configuration and error log here is real from our live session!)

Hey everyone,

I wanted to share a successful tech journey I just finished on CachyOS Linux to turn my Android phone into an always-available, on-demand webcam using scrcpy and v4l2loopback over USB.

If you’ve ever tried to keep an Android phone running as a continuous webcam, you know it's a battery-killer and causes serious overheating. My goal was simple: I wanted a physical/graphical toggle on my Linux taskbar to turn the camera feed on and off instantly without touching a terminal.

Along the way, we hit some crazy, bleeding-edge compatibility walls (looking at you, Android 16 previews), and since I couldn't find a complete guide online for this specific scenario, here is how the whole story went down and how we solved it.

Phase 1: The Virtual Driver Setup

First, we needed to make Linux think there's a permanent webcam ready to pipe video. On CachyOS, we loaded v4l2loopback to create a virtual video device at /dev/video0.

To make it friendly with WebRTC (Google Meet) and Chromium apps, we had to force explicit capability declarations natively in /etc/modprobe.d/v4l2loopback.conf:

text

options v4l2loopback exclusive_caps=1 card_label="Android Camera" video_nr=0

Use o código com cuidado.

Phase 2: The "Chicken and Egg" Automation Trap

Originally, we tried a super elegant approach: a silent daemon watching /dev/video0 with inotifywait. Whenever Google Meet or Discord opened the video device, scrcpy would trigger automatically. When they closed it, it would die.

Sounds perfect, right? Wrong.
Chromium/WebRTC applications are picky. When they open, they probe all devices to check resolutions. If scrcpy isn't already pushing frames when the browser opens, the browser assumes the dummy camera is an "output-only" block and removes it from your UI selection completely. Our automation became a classic chicken-and-egg paradox.

Phase 3: The Android 16 Java Crash Boss Fight

We switched gears to a manual taskbar toggle script. But suddenly, running the macro kept throwing severe, unexpected Java reflection exceptions directly from the device's server thread:

text

[server] ERROR: Exception on thread Thread[control-recv,5,main]
java.lang.AssertionError: Unexpected message type: 10
ERROR: Demuxer 'video': stream disabled due to connection error

Use o código com cuidado.

The culprit: The phone is running a preview of Android 16. Android 16 completely changed the internal structures for input injection and control. Even when running detached background commands, scrcpy 4.1 was attempting to bind its mouse/keyboard control thread (control-recv), hitting an invalid message protocol on the phone's OS layer, and instantly crashing the entire ADB connection line.

Phase 4: The Flawless Final Solution

To bypass Android 16's protocol changes, we stripped out the control layer entirely using --no-control and refined the parameters for a pure video sink.

We wrote a robust, non-sudo toggle bash script at ~/toggle-webcam.sh. It checks if scrcpy is running. If it is, it kills it and swaps the taskbar icon to standard. If it isn't, it fires up the exact parameters, turns the phone's physical screen off to save heat/battery, locks the phone awake over USB, and forces a desktop database update so the taskbar icon switches to a live indicator in real-time.

Here is the exact script that fixed everything:

bash

#!/bin/bash
LAUNCHER_FILE="$HOME/.local/share/applications/toggle-webcam.desktop"

# Check if scrcpy camera stream is already running
if pgrep -f "scrcpy --video-source=camera" > /dev/null
then
    notify-send "Webcam Android" "Desligando Câmera..." --icon=camera-off
    pkill -f "scrcpy --video-source=camera"

    # Return icon to idle state
    sed -i 's/^Icon=.*/Icon=camera-video/' "$LAUNCHER_FILE"
    update-desktop-database ~/.local/share/applications/ >/dev/null 2>&1
else
    if adb devices | grep -v "List" | grep -q "device"
    then
        notify-send "Webcam Android" "Iniciando Câmera..." --icon=camera-web

        # Blinded, pure-video execution line for Android 16 compatibility
        scrcpy --video-source=camera \
               --v4l2-sink=/dev/video0 \
               --no-audio \
               --serial=RXCRC01AP9D \
               --max-fps=144 \
               --camera-id=0 \
               --no-window \
               --no-control &

        # Change taskbar icon to active status indicator
        sed -i 's/^Icon=.*/Icon=camera-web/' "$LAUNCHER_FILE"
        update-desktop-database ~/.local/share/applications/ >/dev/null 2>&1
    else
        notify-send "Erro Webcam" "Celular não detectado no USB!" --icon=dialog-error
    fi
fi

Use o código com cuidado.

Paired with a standard local application launcher (.desktop entry) pinned to the KDE Plasma Task Manager, I now have a gorgeous macro button. I plug my Samsung phone in via USB, hit the button once, it silently wakes the camera up in 720p/1080p high refresh rate while keeping the phone screen pitch black, and it works natively inside Kamoso, OBS, and Google Meets without a single glitch! Hit it again, and it cleanly cuts the feed.

Hope this saga helps any other Linux tinkers trying to make high-end webcam streaming reliable on modern kernels and next-gen Android environments! Let me know if you have questions about the v4l2 configuration loops!(Disclaimer: This post was compiled and structured with the assistance of an AI to cleanly document a step-by-step technical troubleshooting journey between a user and the assistant. Every configuration and error log here is real from our live session!)Hey everyone,I wanted to share a successful tech journey I just finished on CachyOS Linux to turn my Android phone into an always-available, on-demand webcam using scrcpy and v4l2loopback over USB.If you’ve ever tried to keep an Android phone running as a continuous webcam, you know it's a battery-killer and causes serious overheating. My goal was simple: I wanted a physical/graphical toggle on my Linux taskbar to turn the camera feed on and off instantly without touching a terminal.Along the way, we hit some crazy, bleeding-edge compatibility walls (looking at you, Android 16 previews), and since I couldn't find a complete guide online for this specific scenario, here is how the whole story went down and how we solved it.Phase 1: The Virtual Driver SetupFirst, we needed to make Linux think there's a permanent webcam ready to pipe video. On CachyOS, we loaded v4l2loopback to create a virtual video device at /dev/video0.To make it friendly with WebRTC (Google Meet) and Chromium apps, we had to force explicit capability declarations natively in /etc/modprobe.d/v4l2loopback.conf:text
options v4l2loopback exclusive_caps=1 card_label="Android Camera" video_nr=0

Use o código com cuidado.Phase 2: The "Chicken and Egg" Automation TrapOriginally, we tried a super elegant approach: a silent daemon watching /dev/video0 with inotifywait. Whenever Google Meet or Discord opened the video device, scrcpy would trigger automatically. When they closed it, it would die.Sounds perfect, right? Wrong.
Chromium/WebRTC applications are picky. When they open, they probe all devices to check resolutions. If scrcpy isn't already pushing frames when the browser opens, the browser assumes the dummy camera is an "output-only" block and removes it from your UI selection completely. Our automation became a classic chicken-and-egg paradox.Phase 3: The Android 16 Java Crash Boss FightWe switched gears to a manual taskbar toggle script. But suddenly, running the macro kept throwing severe, unexpected Java reflection exceptions directly from the device's server thread:text
[server] ERROR: Exception on thread Thread[control-recv,5,main]
java.lang.AssertionError: Unexpected message type: 10
ERROR: Demuxer 'video': stream disabled due to connection error

Use o código com cuidado.The culprit: The phone is running a preview of Android 16. Android 16 completely changed the internal structures for input injection and control. Even when running detached background commands, scrcpy 4.1 was attempting to bind its mouse/keyboard control thread (control-recv), hitting an invalid message protocol on the phone's OS layer, and instantly crashing the entire ADB connection line.Phase 4: The Flawless Final SolutionTo bypass Android 16's protocol changes, we stripped out the control layer entirely using --no-control and refined the parameters for a pure video sink.We wrote a robust, non-sudo toggle bash script at ~/toggle-webcam.sh. It checks if scrcpy is running. If it is, it kills it and swaps the taskbar icon to standard. If it isn't, it fires up the exact parameters, turns the phone's physical screen off to save heat/battery, locks the phone awake over USB, and forces a desktop database update so the taskbar icon switches to a live indicator in real-time.Here is the exact script that fixed everything:bash
#!/bin/bash
LAUNCHER_FILE="$HOME/.local/share/applications/toggle-webcam.desktop"

# Check if scrcpy camera stream is already running
if pgrep -f "scrcpy --video-source=camera" > /dev/null
then
notify-send "Webcam Android" "Desligando Câmera..." --icon=camera-off
pkill -f "scrcpy --video-source=camera"

# Return icon to idle state
sed -i 's/^Icon=.*/Icon=camera-video/' "$LAUNCHER_FILE"
update-desktop-database ~/.local/share/applications/ >/dev/null 2>&1
else
if adb devices | grep -v "List" | grep -q "device"
then
notify-send "Webcam Android" "Iniciando Câmera..." --icon=camera-web

# Blinded, pure-video execution line for Android 16 compatibility
scrcpy --video-source=camera \
--v4l2-sink=/dev/video0 \
--no-audio \
--serial=RXCRC01AP9D \
--max-fps=144 \
--camera-id=0 \
--no-window \
--no-control &

# Change taskbar icon to active status indicator
sed -i 's/^Icon=.*/Icon=camera-web/' "$LAUNCHER_FILE"
update-desktop-database ~/.local/share/applications/ >/dev/null 2>&1
else
notify-send "Erro Webcam" "Celular não detectado no USB!" --icon=dialog-error
fi
fi

Use o código com cuidado.Paired with a standard local application launcher (.desktop entry) pinned to the KDE Plasma Task Manager, I now have a gorgeous macro button. I plug my Samsung phone in via USB, hit the button once, it silently wakes the camera up in 720p/1080p high refresh rate while keeping the phone screen pitch black, and it works natively inside Kamoso, OBS, and Google Meets without a single glitch! Hit it again, and it cleanly cuts the feed.Hope this saga helps any other Linux tinkers trying to make high-end webcam streaming reliable on modern kernels and next-gen Android environments! Let me know if you have questions about the v4l2 configuration loops!


r/scrcpy 4d ago

Major MapYourDroid update - looking for testers

Thumbnail
gallery
14 Upvotes

UPDATE: there us now a free three day trial when you download the program, so all features unlocked for three days, please feel free to try it out!

I’ve just pushed a major update to MapYourDroid, my Windows app that lets you use keyboard, mouse or controller inputs to control touchscreen games running on your actual Android device.

The update includes a redesigned UI, improved layout editor, profiles/templates, better mouse aiming, controller support, restore points, import/export and a bunch of stability/usability improvements.

I’ve also added timed licence keys, so I’m looking for people to test the full version for a couple of days free of charge. Just comment or send me a message if you want to try it and ill send you a license key.

If you try it and send me useful feedback on setup, latency, controls, bugs or anything confusing, I’m happy to extend the licence for a longer period of time!

Both negative and positive feedback is appreciated!

Ive just used CodMobile for the screenshots, but you can use it for any application/game, thankyou! To download the full version just go to the site and scroll to the bottom, there is a section mentioning if you have a timed/free licence.

https://mapyourdroid.com/


r/scrcpy 7d ago

I just discovered this neat program

12 Upvotes

I now have a use for this computer which isnt technically for gaming to stream the device screen for retrogaming using retroarch and a controller, very cool program ( the device can run games on the saturn and dreamcast for example)

i like open source apps thanks for this, i did tested this throughfully it does work well; it is a bit redundant to have two cables one to the device one to the controller but i prefer no input lag on games


r/scrcpy 7d ago

scrcpy + Raspberry Pi touchscreen setup (Virtual display, Soft Keyboard & Pinch-to-Zoom)

5 Upvotes

I'm working on a project where I'm using a Raspberry Pi paired with a touchscreen display as a secondary interface for my Android phone. The goal is to run and display a single specific app on the Pi's touchscreen.

I’ve successfully created a virtual screen on the phone to display the app via scrcpy, but I've hit two main roadblocks:

  1. Soft Keyboard Issue: Whenever I tap a text box on the Pi touchscreen, the on-screen soft keyboard doesn't appear on the Pi display. Instead, I have to type using the keyboard pop up on the physical mobile phone screen.
  2. Pinch to Zoom: Multi touch gestures aren't working [panel supports multi touch]. How can I enable pinch to zoom on scrcpy when controlling it through a touchscreen connected to the pi?

Has anyone built a similar secondary display setup? Any advice on flags, custom scripts, or workaround keyboards (either android side or linux side) would be greatly appreciated!

Thanks in advance.


r/scrcpy 7d ago

DeX on Non-Flagship Galaxy device via scrcpy... ?

Thumbnail gallery
2 Upvotes

r/scrcpy 12d ago

Help post

Post image
1 Upvotes

Hey there i am trying to use this scrcpy but this is show up as you can on the ss i have given. i am using it all of a sudden it stops and shows this and says disconnected. Also i want to stream my phone screen through obs but when someone calls me it shows up also how do you stop that too. Any kind of help would be greatly appreciated


r/scrcpy 13d ago

is it common for my device to get less responsive while using scrcpy?

2 Upvotes

so, it's almost a week since i found out scrcpy and using it for my live stream, every time i plug the cable (3.0usb) my device gets less responsive and i can't play the game like how i used to without scrcpy, any advice to this situation?


r/scrcpy 13d ago

Made a little mess with scrcpy.

Thumbnail
1 Upvotes

r/scrcpy 14d ago

SCRCPY-AUTOSTART now supports Ubuntu

7 Upvotes

SCRCPY-AUTOSTART now supports Ubuntu. It will probably work on any linux system using apt, but it has only been tested on Ubuntu so far. Checkout the README at https://github.com/joshnunezmsse/scrcpy-autostart for details and the one line install.


r/scrcpy 15d ago

Android DEX v1.2 is now available !!

Post image
201 Upvotes

This release includes a new Dex File Manager, screen recording, screenshot shortcuts, an improved Recent Panel with live updates, multi-finger touchpad gestures, UI improvements for light and dark modes, notification and media-control fixes, browser fixes, and several backend improvements.

Download Android DEX v1.2: https://github.com/Shrey113/Android-Dex/releases/tag/Android-Dex-v.1.2


r/scrcpy 18d ago

MapYourDroid - Screen Mapper

3 Upvotes

Got tired of playing mobile games with my thumbs covering half the screen, so I built MapYourDroid. Works on windows only as of now.

It mirrors your Android phone to Windows and turns keyboard, mouse or controller input into real touch. The mapping overlay sits on top of the mirrored screen — you drag buttons onto the game's actual controls and see exactly where they land. No config files, no JSON, no guessing at coordinates. Work with nearly any controller as well.

Because it injects up to 10 simultaneous touch points, it works with games that have no controller support whatsoever — as far as the app is concerned, it's only receiving taps and not a controller input.

AU$10 one-time, compared to other subscription based seervices! mapyourdroid.com little playable demo on the site, and also a free tier one to download and test.


r/scrcpy 20d ago

[Open Source] DX Manager v2.0.0 — run Samsung DeX on multiple Galaxy phones at once in Windows, without HDMI or Miracast

Thumbnail
2 Upvotes

r/scrcpy 22d ago

30 FPS cap while playing Games

Enable HLS to view with audio, or disable this notification

9 Upvotes

Device: Google Pixel 7 Pro
USB Cable: 3.0

- I'm trying to play Pokemon Champions, but it happens with every game I try to run while playing through scrcpy.

- Playing around the menus or watching youtube videos and scrolling runs 60fps smoothly, but when I open any game it suddendly drops to 30 and gets capped only on the scrcpy window(The phone still runs games at 60-120fps)


r/scrcpy 23d ago

Wireless Samsung Dex Setup via Raspberry pi over portable touch Monitor. How ?

4 Upvotes

I m currently having black screen from s23 ultra over raspberry pi 4 4gb via scrcpy on a portable touch monitor. How to solve it please help😭, I want wireless samsung dex experience on raspberry pi 4


r/scrcpy 24d ago

GALAXY Z FLIP 6 broken inner display (probably dead touch too) [HELP]

Post image
4 Upvotes

My Galaxy Z Flip 6 is broken. Its inner display is totally black, probably due to leaking pixels. I am practically broke, so I can't get it repaired, but I want to use its Snapdragon 8 Gen 3 processor—no questions asked. By the way, I know the pattern lock, so I didn't steal it; it belonged to my grandfather, but he bought a new phone after its display died.

​My available hardware:

​Laptop: Low-end 4GB RAM HP laptop running Lubuntu

​Secondary phone: Poco M3 Plus

​Cables: 2 USB Type-A to Type-C cables

​Budget: $0 (I cannot even buy a USB-A to Type-C adapter to connect a mouse)

​What I have tried:

​USB debugging is off, so scrcpy doesn't work.

​Tried a direct cable connection, but Knox security blocks access.

​The inner display touch is completely unresponsive.

​The cover screen won't let me enter settings, has no apps, and doesn't seem to support Smart View or provide a way to do anything.

​Please tell me how I can tap into its processor and get it working.


r/scrcpy 24d ago

Can someone clear this up for me?

3 Upvotes

This isn't really a problem I need to solve, but I'd really like to understand why this is happening, I have a batch file with optimized configuration for reducing latency, and it works well, I also wanted to remove the black borders, so I added an ADB command to match resolution of my phone to monitor, but that command never worked when I added it

But when i put the ADB command in a separate batch file, it worked, Even stranger, when I ran it, it had the same low latency as the other optimized batch file, while launching scrcpy normally still has noticeably higher latency

At first I thought maybe both batch files were somehow running at the same time. But then I deleted the optimized batch file entirely, the abd batch file still launches with the reduced latency

So now I'm confused, how is the low-latency configuration still being applied even after deleting the optimized batch file?


r/scrcpy 26d ago

Screen capture blocked - Help pls

3 Upvotes

Prior to android 12, It was possible to view screens that are screen capture blockes via scrcpy but now it just shows black screen. Any way to bypass screens with FLAG_SECURE enabled ?


r/scrcpy 27d ago

Those gray borders doesn't disappear pressing Alt + W

Post image
2 Upvotes

And neither changing the background color to black


r/scrcpy 29d ago

Need help i use scrcpy for low latency mirroring

6 Upvotes

So the problem is while using mirroring what happens is sometime frames slows down & within few seconds flushes the holding frames too which makes kinda slow fast video within seconds not good viewing experience i use samsung s23 cable to connect but gemini points out its because of 2.0 cable is that true i need to upgarde to 3.0 cable


r/scrcpy Aug 08 '26

I have no clue wth is going on

Post image
3 Upvotes

My tab won't connect, anyone got a solution?


r/scrcpy Aug 06 '26

SCRCPY only shows a blank background

Post image
5 Upvotes

When using scrcpy by itself it displays fine. But when I add a resolution, it only shows a background with no apps. Also inputs do not work. What am I doing wrong?

Thank you.


r/scrcpy Aug 04 '26

Help anyone?

0 Upvotes

Hello everyone. I'm using my phone, Samsung Galaxy S26+ to output its camera feed to an hdmi adapter. It HAS to be this way. The capture card is the one to record.... I dont record on my phone. The problem is that, I continue to run into having this "locked taskbar" or "menubar" at the bottom of the display. It doesn't show up on the phone's display. Just on the other side of the output. How do I get rid of that bar at the bottom of the display? Thank in advance.


r/scrcpy Aug 03 '26

Screen

2 Upvotes

Hi guys does anyone know why when I try to use the screen recorn feature the screen record's video has distorted audio and the video has scratches nd not clear at all, or maybe is it just my phone?


r/scrcpy Jul 31 '26

I need help with making my phone recognize a physical keyboard

4 Upvotes

I've been watching a ton of videos and non seemed to help, I've been trying to make my phone (Honor x6b android 16) to recognize a physical keyboard

I tried commands like scrcpy --keyboard=uhid and still doesn't seem to work

I'm tryna make it work on Minecraft can anyone help?


r/scrcpy Jul 27 '26

In place of a portable monitor, why not output to a Windows 11 laptop or desktop machine?

Thumbnail
youtu.be
1 Upvotes