Wednesday, November 23, 2022
HomeHackerShow And Management Your Android Machine

Show And Management Your Android Machine




pronounced “screen copy

Learn in one other language

This utility supplies show and management of Android gadgets linked by way of
USB or over TCP/IP. It doesn’t require any root entry.
It really works on GNU/Linux, Home windows and macOS.

It focuses on:

Its options embrace:

Necessities

The Android machine requires a minimum of API 21 (Android 5.0).

Be sure you allow adb debugging in your machine(s).

On some gadgets, you additionally have to allow a further possibility to
management it utilizing a keyboard and mouse.

Get the app

Abstract

  • Linux: apt set up scrcpy
  • Home windows: obtain
  • macOS: brew set up scrcpy

Construct from sources: BUILD (simplified course of)

Linux

On Debian and Ubuntu:

On Arch Linux:

A Snap bundle is offered: scrcpy.

For Fedora, a COPR bundle is offered: scrcpy.

For Gentoo, an Ebuild is offered: scrcpy/.

You may also construct the app manually (simplified
course of
).

Home windows

For Home windows, a prebuilt archive with all of the dependencies (together with adb) is
accessible:

It’s also accessible in Chocolatey:

choco set up scrcpy
choco set up adb # if you do not have it but

And in Scoop:

scoop set up scrcpy
scoop set up adb # if you do not have it but

You may also construct the app manually.

macOS

The appliance is offered in Homebrew. Simply set up it:

You want adb, accessible out of your PATH. If you do not have it but:

brew set up android-platform-tools

It is also accessible in MacPorts, which units up adb for you:

You may also construct the app manually.

Run

Plug an Android machine into your laptop, and execute:

It accepts command-line arguments, listed by:

Options

Seize configuration

Cut back measurement

Typically, it’s helpful to reflect an Android machine at a decrease decision to
improve efficiency.

To restrict each the width and top to some worth (e.g. 1024):

scrcpy --max-size 1024
scrcpy -m 1024 # brief model

The opposite dimension is computed in order that the Android machine facet ratio is
preserved. That manner, a tool in 1920×1080 might be mirrored at 1024×576.

Change bit-rate

The default bit-rate is 8 Mbps. To alter the video bitrate (e.g. to 2 Mbps):

scrcpy --bit-rate 2M
scrcpy -b 2M # brief model

Restrict body charge

The seize body charge might be restricted:

That is formally supported since Android 10, however may fit on earlier variations.

The precise seize framerate could also be printed to the console:

It could even be enabled or disabled at any time with MOD+i.

Crop

The machine display could also be cropped to reflect solely a part of the display.

That is helpful, for instance, to reflect just one eye of the Oculus Go:

scrcpy --crop 1224:1440:0:0   # 1224x1440 at offset (0,0)

If --max-size can also be specified, resizing is utilized after cropping.

Lock video orientation

To lock the orientation of the mirroring:

scrcpy --lock-video-orientation     # preliminary (present) orientation
scrcpy --lock-video-orientation=0 # pure orientation
scrcpy --lock-video-orientation=1 # 90° counterclockwise
scrcpy --lock-video-orientation=2 # 180°
scrcpy --lock-video-orientation=3 # 90° clockwise

This impacts recording orientation.

The window might also be rotated independently.

Encoder

Some gadgets have multiple encoder, and a few of them might trigger points or
crash. It’s doable to pick a unique encoder:

scrcpy --encoder OMX.qcom.video.encoder.avc

To listing the accessible encoders, you possibly can go an invalid encoder title; the
error will give the accessible encoders:

Seize

Recording

It’s doable to report the display whereas mirroring:

scrcpy --record file.mp4
scrcpy -r file.mkv

To disable mirroring whereas recording:

scrcpy --no-display --record file.mp4
scrcpy -Nr file.mkv
# interrupt recording with Ctrl+C

“Skipped frames” are recorded, even when they aren’t displayed in actual time (for
efficiency causes). Frames are timestamped on the machine, so packet delay
variation
doesn’t impression the recorded file.

v4l2loopback

On Linux, it’s doable to ship the video stream to a v4l2 loopback machine, so
that the Android machine might be opened like a webcam by any v4l2-capable device.

The module v4l2loopback should be put in:

sudo apt set up v4l2loopback-dkms

To create a v4l2 machine:

sudo modprobe v4l2loopback

It will create a brand new video machine in /dev/videoN, the place N is an integer
(extra choices can be found
to create a number of gadgets or gadgets with particular IDs).

To listing the enabled gadgets:

# requires v4l-utils bundle
v4l2-ctl --list-devices

# easy however is perhaps enough
ls /dev/video*

To begin scrcpy utilizing a v4l2 sink:

scrcpy --v4l2-sink=/dev/videoN
scrcpy --v4l2-sink=/dev/videoN --no-display # disable mirroring window
scrcpy --v4l2-sink=/dev/videoN -N # brief model

(exchange N with the machine ID, verify with ls /dev/video*)

As soon as enabled, you possibly can open your video stream with a v4l2-capable device:

ffplay -i /dev/videoN
vlc v4l2:///dev/videoN # VLC may add some buffering delay

For instance, you would seize the video inside OBS.

Buffering

It’s doable so as to add buffering. This will increase latency, however reduces jitter (see
#2464).

The choice is offered for show buffering:

scrcpy --display-buffer=50  # add 50 ms buffering for show

and V4L2 sink:

scrcpy --v4l2-buffer=500    # add 500 ms buffering for v4l2 sink

Connection

TCP/IP (wi-fi)

Scrcpy makes use of adb to speak with the machine, and adb can join to a
machine over TCP/IP. The machine should be linked on the identical community because the
laptop.

Computerized

An possibility --tcpip permits to configure the connection routinely. There are
two variants.

If the machine (accessible at 192.168.1.1 on this instance) already listens on a
port (usually 5555) for incoming adb connections, then run:

scrcpy --tcpip=192.168.1.1       # default port is 5555
scrcpy --tcpip=192.168.1.1:5555

If adb TCP/IP mode is disabled on the machine (or if you do not know the IP
tackle), join the machine over USB, then run:

scrcpy --tcpip    # with out arguments

It can routinely discover the machine IP tackle, allow TCP/IP mode, then
connect with the machine earlier than beginning.

Guide

Alternatively, it’s doable to allow the TCP/IP connection manually utilizing
adb:

  1. Plug the machine right into a USB port in your laptop.

  2. Join the machine to the identical Wi-Fi community as your laptop.

  3. Get your machine IP tackle, in Settings → About cellphone → Standing, or by
    executing this command:

    adb shell ip route | awk '{print $9}'
  4. Allow adb over TCP/IP in your machine: adb tcpip 5555.

  5. Unplug your machine.

  6. Hook up with your machine: adb join DEVICE_IP:5555 (exchange DEVICE_IP
    with the machine IP tackle you discovered)
    .

  7. Run scrcpy as common.

Since Android 11, a Wi-fi debugging possibility permits to bypass
having to bodily join your machine on to your laptop.

If the connection randomly drops, run your scrcpy command to reconnect. If it
says there aren’t any gadgets/emulators discovered, strive working adb join DEVICE_IP:5555 once more, after which scrcpy as common. If it nonetheless says there are
none discovered, strive working adb disconnect, after which run these two instructions once more.

It could be helpful to lower the bit-rate and the decision:

scrcpy --bit-rate 2M --max-size 800
scrcpy -b2M -m800 # brief model

Multi-devices

If a number of gadgets are listed in adb gadgets, you possibly can specify the serial:

scrcpy --serial 0123456789abcdef
scrcpy -s 0123456789abcdef # brief model

The serial might also be supplied by way of the surroundings variable ANDROID_SERIAL
(additionally utilized by adb).

If the machine is linked over TCP/IP:

scrcpy --serial 192.168.0.1:5555
scrcpy -s 192.168.0.1:5555 # brief model

If just one machine is linked by way of both USB or TCP/IP, it’s doable to
choose it routinely:

# Choose the one machine linked by way of USB
scrcpy -d # like adb -d
scrcpy --select-usb # lengthy model

# Choose the one machine linked by way of TCP/IP
scrcpy -e # like adb -e
scrcpy --select-tcpip # lengthy model

You can begin a number of situations of scrcpy for a number of gadgets.

Autostart on machine connection

You may use AutoAdb:

Tunnels

To connect with a distant machine, it’s doable to attach an area adb consumer to
a distant adb server (supplied they use the identical model of the adb
protocol).

Distant ADB server

To connect with a distant adb server, make the server hear on all interfaces:

adb kill-server
adb -a nodaemon server begin
# maintain this open

Warning: all communications between purchasers and the adb server are
unencrypted.

Suppose that this server is accessible at 192.168.1.2. Then, from one other
terminal, run scrcpy:

# in bash
export ADB_SERVER_SOCKET=tcp:192.168.1.2:5037
scrcpy --tunnel-host=192.168.1.2
:: in cmd
set ADB_SERVER_SOCKET=tcp:192.168.1.2:5037
scrcpy --tunnel-host=192.168.1.2
# in PowerShell
$env:ADB_SERVER_SOCKET = 'tcp:192.168.1.2:5037'
scrcpy --tunnel-host=192.168.1.2

By default, scrcpy makes use of the native port used for adb ahead tunnel
institution (usually 27183, see --port). It’s also doable to pressure a
completely different tunnel port (it could be helpful in additional advanced conditions, when extra
redirections are concerned):

scrcpy --tunnel-port=1234
SSH tunnel

To speak with a distant adb server securely, it’s preferable to make use of an
SSH tunnel.

First, ensure the adb server is working on the distant laptop:

Then, set up an SSH tunnel:

# native  5038 --> distant  5037
# native 27183 <-- distant 27183
ssh -CN -L5038:localhost:5037 -R27183:localhost:27183 your_remote_computer
# maintain this open

From one other terminal, run scrcpy:

# in bash
export ADB_SERVER_SOCKET=tcp:localhost:5038
scrcpy
:: in cmd
set ADB_SERVER_SOCKET=tcp:localhost:5038
scrcpy
# in PowerShell
$env:ADB_SERVER_SOCKET = 'tcp:localhost:5038'
scrcpy

To keep away from enabling distant port forwarding, you would pressure a ahead connection
as a substitute (discover the -L as a substitute of -R):

# native  5038 --> distant  5037
# native 27183 --> distant 27183
ssh -CN -L5038:localhost:5037 -L27183:localhost:27183 your_remote_computer
# maintain this open

From one other terminal, run scrcpy:

# in bash
export ADB_SERVER_SOCKET=tcp:localhost:5038
scrcpy --force-adb-forward
:: in cmd
set ADB_SERVER_SOCKET=tcp:localhost:5038
scrcpy --force-adb-forward
# in PowerShell
$env:ADB_SERVER_SOCKET = 'tcp:localhost:5038'
scrcpy --force-adb-forward

Like for wi-fi connections, it could be helpful to cut back high quality:

scrcpy -b2M -m800 --max-fps 15

Window configuration

Title

By default, the window title is the machine mannequin. It may be modified:

scrcpy --window-title 'My machine'

Place and measurement

The preliminary window place and measurement could also be specified:

scrcpy --window-x 100 --window-y 100 --window-width 800 --window-height 600

Borderless

To disable window decorations:

scrcpy --window-borderless

At all times on high

To maintain the scrcpy window at all times on high:

Fullscreen

The app could also be began straight in fullscreen:

scrcpy --fullscreen
scrcpy -f # brief model

Fullscreen can then be toggled dynamically with MOD+f.

Rotation

The window could also be rotated:

Attainable values:

  • 0: no rotation
  • 1: 90 levels counterclockwise
  • 2: 180 levels
  • 3: 90 levels clockwise

The rotation may also be modified dynamically with MOD+
(left) and MOD+ (proper).

Word that scrcpy manages 3 completely different rotations:

  • MOD+r requests the machine to modify between portrait
    and panorama (the present working app might refuse, if it doesn’t assist the
    requested orientation).
  • --lock-video-orientation modifications the mirroring
    orientation (the orientation of the video despatched from the machine to the
    laptop). This impacts the recording.
  • --rotation (or MOD+/MOD+)
    rotates solely the window content material. This impacts solely the show, not the
    recording.

Different mirroring choices

Learn-only

To disable controls (all the things which may work together with the machine: enter keys,
mouse occasions, drag&drop information):

scrcpy --no-control
scrcpy -n

Show

If a number of shows can be found, it’s doable to pick the show to
mirror:

The listing of show ids might be retrieved by:

adb shell dumpsys show   # search "mDisplayId=" within the output

The secondary show might solely be managed if the machine runs a minimum of Android
10 (in any other case it’s mirrored as read-only).

Keep awake

To forestall the machine from sleeping after a delay when the machine is plugged in:

scrcpy --stay-awake
scrcpy -w

The preliminary state is restored when scrcpy is closed.

Flip display off

It’s doable to show the machine display off whereas mirroring on begin with a
command-line possibility:

scrcpy --turn-screen-off
scrcpy -S

Or by urgent MOD+o at any time.

To show it again on, press MOD+Shift+o.

On Android, the POWER button at all times turns the display on. For comfort, if
POWER is distributed by way of scrcpy (by way of right-click or MOD+p),
it’ll pressure to show the display off after a small delay (on a greatest effort
foundation). The bodily POWER button will nonetheless trigger the display to be turned
on.

It may also be helpful to forestall the machine from sleeping:

scrcpy --turn-screen-off --stay-awake
scrcpy -Sw

Energy off on shut

To show the machine display off when closing scrcpy:

scrcpy --power-off-on-close

Energy on on begin

By default, on begin, the machine is powered on.

To forestall this conduct:

Present touches

For shows, it could be helpful to point out bodily touches (on the bodily
machine).

Android supplies this characteristic in Builders choices.

Scrcpy supplies an choice to allow this characteristic on begin and restore the
preliminary worth on exit:

scrcpy --show-touches
scrcpy -t

Word that it solely exhibits bodily touches (by a finger on the machine).

Disable screensaver

By default, scrcpy doesn’t forestall the screensaver from working on the
laptop.

To disable it:

scrcpy --disable-screensaver

Enter management

Rotate machine display

Press MOD+r to modify between portrait and panorama
modes.

Word that it rotates provided that the applying in foreground helps the
requested orientation.

Copy-paste

Any time the Android clipboard modifications, it’s routinely synchronized to the
laptop clipboard.

Any Ctrl shortcut is forwarded to the machine. Specifically:

  • Ctrl+c usually copies
  • Ctrl+x usually cuts
  • Ctrl+v usually pastes (after computer-to-device
    clipboard synchronization)

This usually works as you anticipate.

The precise conduct is dependent upon the lively utility although. For instance,
Termux sends SIGINT on Ctrl+c as a substitute, and Ok-9 Mail
composes a brand new message.

To repeat, minimize and paste in such circumstances (however solely supported on Android >= 7):

  • MOD+c injects COPY
  • MOD+x injects CUT
  • MOD+v injects PASTE (after computer-to-device
    clipboard synchronization)

As well as, MOD+Shift+v injects the pc
clipboard textual content as a sequence of key occasions. That is helpful when the element
doesn’t settle for textual content pasting (for instance in Termux), however it may break
non-ASCII content material.

WARNING: Pasting the pc clipboard to the machine (both by way of
Ctrl+v or MOD+v) copies the content material
into the Android clipboard. As a consequence, any Android utility might learn
its content material. It is best to keep away from pasting delicate content material (like passwords) that
manner.

Some Android gadgets don’t behave as anticipated when setting the machine clipboard
programmatically. An possibility --legacy-paste is supplied to alter the conduct
of Ctrl+v and MOD+v in order that they
additionally inject the pc clipboard textual content as a sequence of key occasions (the identical
manner as MOD+Shift+v).

To disable automated clipboard synchronization, use
--no-clipboard-autosync.

Pinch-to-zoom

To simulate “pinch-to-zoom”: Ctrl+click-and-move.

Extra exactly, maintain down Ctrl whereas urgent the left-click button.
Till the left-click button is launched, all mouse actions scale and rotate
the content material (if supported by the app) relative to the middle of the display.

Technically, scrcpy generates further contact occasions from a “digital finger”
at a location inverted by way of the middle of the display.

Bodily keyboard simulation (HID)

By default, scrcpy makes use of Android key or textual content injection: it really works in all places,
however is restricted to ASCII.

Alternatively, scrcpy can simulate a bodily USB keyboard on Android to
present a greater enter expertise (utilizing USB HID over AOAv2): the
digital keyboard is disabled and it really works for all characters and IME.

Nevertheless, it solely works if the machine is linked by way of USB.

Word: On Home windows, it could solely work in OTG mode, not whereas mirroring (it
shouldn’t be doable to open a USB machine whether it is already open by one other course of
just like the adb daemon).

To allow this mode:

scrcpy --hid-keyboard
scrcpy -Ok # brief model

If it fails for some cause (for instance as a result of the machine shouldn’t be linked by way of
USB), it routinely fallbacks to the default mode (with a log within the
console). This enables utilizing the identical command line choices when linked over
USB and TCP/IP.

On this mode, uncooked key occasions (scancodes) are despatched to the machine, independently
of the host key mapping. Due to this fact, in case your keyboard format doesn’t match, it
should be configured on the Android machine, in Settings → System → Languages and
enter → Bodily keyboard.

This settings web page might be began straight:

adb shell am begin -a android.settings.HARD_KEYBOARD_SETTINGS

Nevertheless, the choice is just accessible when the HID keyboard is enabled (or when
a bodily keyboard is linked).

Bodily mouse simulation (HID)

Equally to the bodily keyboard simulation, it’s doable to simulate a
bodily mouse. Likewise, it solely works if the machine is linked by USB.

By default, scrcpy makes use of Android mouse occasions injection with absolute
coordinates. By simulating a bodily mouse, a mouse pointer seems on the
Android machine, and relative mouse movement, clicks and scrolls are injected.

To allow this mode:

scrcpy --hid-mouse
scrcpy -M # brief model

You may also add --forward-all-clicks to ahead all mouse
buttons
.

When this mode is enabled, the pc mouse is “captured” (the mouse pointer
disappears from the pc and seems on the Android machine as a substitute).

Particular seize keys, both Alt or Tremendous, toggle
(disable or allow) the mouse seize. Use certainly one of them to offer the management of
the mouse again to the pc.

OTG

It’s doable to run scrcpy with solely bodily keyboard and mouse simulation
(HID), as if the pc keyboard and mouse had been plugged on to the machine
by way of an OTG cable.

On this mode, adb (USB debugging) shouldn’t be obligatory, and mirroring is disabled.

To allow OTG mode:

scrcpy --otg
# Cross the serial if a number of USB gadgets can be found
scrcpy --otg -s 0123456789abcdef

It’s doable to allow solely HID keyboard or HID mouse:

scrcpy --otg --hid-keyboard              # keyboard solely
scrcpy --otg --hid-mouse # mouse solely
scrcpy --otg --hid-keyboard --hid-mouse # keyboard and mouse
# for comfort, allow each by default
scrcpy --otg # keyboard and mouse

Like --hid-keyboard and --hid-mouse, it solely works if the machine is
linked by USB.

Textual content injection desire

Two sorts of occasions are generated when typing textual content:

  • key occasions, signaling {that a} secret is pressed or launched;
  • textual content occasions, signaling {that a} textual content has been entered.

By default, letters are injected utilizing key occasions, in order that the keyboard behaves
as anticipated in video games (usually for WASD keys).

However this will likely trigger points. When you encounter such an issue, you
can keep away from it by:

(however it will break keyboard conduct in video games)

Quite the opposite, you would pressure to at all times inject uncooked key occasions:

These choices haven’t any impact on HID keyboard (all key occasions are despatched as
scancodes on this mode).

Key repeat

By default, holding a key down generates repeated key occasions. This may trigger
efficiency issues in some video games, the place these occasions are ineffective anyway.

To keep away from forwarding repeated key occasions:

This feature has no impact on HID keyboard (key repeat is dealt with by Android
straight on this mode).

Proper-click and middle-click

By default, right-click triggers BACK (or POWER on) and middle-click triggers
HOME. To disable these shortcuts and ahead the clicks to the machine as a substitute:

scrcpy --forward-all-clicks

File drop

Set up APK

To put in an APK, drag & drop an APK file (ending with .apk) to the scrcpy
window.

There isn’t any visible suggestions, a log is printed to the console.

Push file to machine

To push a file to /sdcard/Obtain/ on the machine, drag & drop a (non-APK)
file to the scrcpy window.

There isn’t any visible suggestions, a log is printed to the console.

The goal listing might be modified on begin:

scrcpy --push-target=/sdcard/Motion pictures/

Audio forwarding

Audio shouldn’t be forwarded by scrcpy. Use sndcpy.

Additionally see difficulty #14.

Shortcuts

Within the following listing, MOD is the shortcut modifier. By default, it is
(left) Alt or (left) Tremendous.

It may be modified utilizing --shortcut-mod. Attainable keys are lctrl, rctrl,
lalt, ralt, lsuper and rsuper. For instance:

# use RCtrl for shortcuts
scrcpy --shortcut-mod=rctrl

# use both LCtrl+LAlt or LSuper for shortcuts
scrcpy --shortcut-mod=lctrl+lalt,lsuper

Tremendous is usually the Home windows or Cmd key.

Motion Shortcut
Swap fullscreen mode MOD+f
Rotate show left MOD+ (left)
Rotate show proper MOD+ (proper)
Resize window to 1:1 (pixel-perfect) MOD+g
Resize window to take away black borders MOD+w | Double-left-click¹
Click on on HOME MOD+h | Center-click
Click on on BACK MOD+b | Proper-click²
Click on on APP_SWITCH MOD+s | 4th-click³
Click on on MENU (unlock display)⁴ MOD+m
Click on on VOLUME_UP MOD+ (up)
Click on on VOLUME_DOWN MOD+ (down)
Click on on POWER MOD+p
Energy on Proper-click²
Flip machine display off (maintain mirroring) MOD+o
Flip machine display on MOD+Shift+o
Rotate machine display MOD+r
Increase notification panel MOD+n | Fifth-click³
Increase settings panel MOD+n+n | Double-Fifth-click³
Collapse panels MOD+Shift+n
Copy to clipboard⁵ MOD+c
Minimize to clipboard⁵ MOD+x
Synchronize clipboards and paste⁵ MOD+v
Inject laptop clipboard textual content MOD+Shift+v
Allow/disable FPS counter (on stdout) MOD+i
Pinch-to-zoom Ctrl+click-and-move
Drag & drop APK file Set up APK from laptop
Drag & drop non-APK file Push file to machine

¹Double-click on black borders to take away them.
²Right-click turns the display on if it was off, presses BACK in any other case.
³4th and Fifth mouse buttons, in case your mouse has them.
⁴For react-native apps in growth, MENU triggers growth menu.
⁵Only on Android >= 7.

Shortcuts with repeated keys are executed by releasing and urgent the important thing a
second time. For instance, to execute “Increase settings panel”:

  1. Press and maintain urgent MOD.
  2. Then double-press n.
  3. Lastly, launch MOD.

All Ctrl+key shortcuts are forwarded to the machine, so they’re
dealt with by the lively utility.

Customized paths

To make use of a selected adb binary, configure its path within the surroundings variable
ADB:

To override the trail of the scrcpy-server file, configure its path in
SCRCPY_SERVER_PATH.

To override the icon, configure its path in SCRCPY_ICON_PATH.

Why the title scrcpy?

A colleague challenged me to discover a title as unpronounceable as gnirehtet.

strcpy copies a string; scrcpy copies a screen.

The way to construct?

See BUILD.

Frequent points

See the FAQ.

Builders

Learn the builders web page.

Licence

Articles

Contact

When you encounter a bug, please learn the FAQ first, then open an difficulty.

For basic questions or discussions, you too can use:

Translations

Translations of this README in different languages can be found within the wiki.

Solely this README file is assured to be up-to-date.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments