Scrcpy – Display And Control Your Android Device



pronounced “screen copy

It focuses on:

Its features include:

The Android device requires at least API 21 (Android 5.0).

On some devices, you also need to enable an additional option to control it using a keyboard and mouse.

On Debian and Ubuntu:

On Arch Linux:

For Windows, a prebuilt archive with all the dependencies (including adb) is available:

You need adb, accessible from your PATH. If you don’t have it yet:

Plug an Android device into your computer, and execute:

It accepts command-line arguments, listed by:

Sometimes, it is useful to mirror an Android device at a lower resolution to increase performance.

To limit both the width and height to some value (e.g. 1024):

The other dimension is computed so that the Android device aspect ratio is preserved. That way, a device in 1920×1080 will be mirrored at 1024×576.

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

The capture frame rate can be limited:

This is officially supported since Android 10, but may work on earlier versions.

The actual capture framerate may be printed to the console:

It may also be enabled or disabled at any time with MOD+i.

The device screen may be cropped to mirror only part of the screen.

This is useful, for example, to mirror only one eye of the Oculus Go:

If --max-size is also specified, resizing is applied after cropping.

To lock the orientation of the mirroring:

This affects recording orientation.

Some devices have more than one encoder, and some of them may cause issues or crash. It is possible to select a different encoder:

To list the available encoders, you can pass an invalid encoder name; the error will give the available encoders:

It is possible to record the screen while mirroring:

To disable mirroring while recording:

On Linux, it is possible to send the video stream to a v4l2 loopback device, so that the Android device can be opened like a webcam by any v4l2-capable tool.

The module v4l2loopback must be installed:

To create a v4l2 device:

To list the enabled devices:

To start scrcpy using a v4l2 sink:

(replace N with the device ID, check with ls /dev/video*)

Once enabled, you can open your video stream with a v4l2-capable tool:

It is possible to add buffering. This increases latency, but reduces jitter (see #2464).

The option is available for display buffering:

and V4L2 sink:

An option --tcpip allows to configure the connection automatically. There are two variants.

If the device (accessible at 192.168.1.1 in this example) already listens on a port (typically 5555) for incoming adb connections, then run:

If adb TCP/IP mode is disabled on the device (or if you don’t know the IP address), connect the device over USB, then run:

It will automatically find the device IP address, enable TCP/IP mode, then connect to the device before starting.

Alternatively, it is possible to enable the TCP/IP connection manually using adb:

Plug the device into a USB port on your computer.

Connect the device to the same Wi-Fi network as your computer.

Get your device IP address, in Settings → About phone → Status, or by executing this command:

Enable adb over TCP/IP on your device: adb tcpip 5555.

Unplug your device.

Connect to your device: adb connect DEVICE_IP:5555 (replace DEVICE_IPwith the device IP address you found).

Run scrcpy as usual.

If the connection randomly drops, run your scrcpy command to reconnect. If it says there are no devices/emulators found, try running adb connect DEVICE_IP:5555 again, and then scrcpy as usual. If it still says there are none found, try running adb disconnect, and then run those two commands again.

It may be useful to decrease the bit-rate and the resolution:

If several devices are listed in adb devices, you can specify the serial:

The serial may also be provided via the environment variable ANDROID_SERIAL(also used by adb).

If the device is connected over TCP/IP:

If only one device is connected via either USB or TCP/IP, it is possible to select it automatically:

You can start several instances of scrcpy for several devices.

To connect to a remote device, it is possible to connect a local adb client to a remote adb server (provided they use the same version of the adbprotocol).

To connect to a remote adb server, make the server listen on all interfaces:

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

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

By default, scrcpy uses the local port used for adb forward tunnel establishment (typically 27183, see --port). It is also possible to force a different tunnel port (it may be useful in more complex situations, when more redirections are involved):

To communicate with a remote adb server securely, it is preferable to use an SSH tunnel.

First, make sure the adb server is running on the remote computer:

Then, establish an SSH tunnel:

From another terminal, run scrcpy:

To avoid enabling remote port forwarding, you could force a forward connection instead (notice the -L instead of -R):

From another terminal, run scrcpy:

Like for wireless connections, it may be useful to reduce quality:

By default, the window title is the device model. It can be changed:

The initial window position and size may be specified:

To disable window decorations:

To keep the scrcpy window always on top:

The app may be started directly in fullscreen:

Fullscreen can then be toggled dynamically with MOD+f.

The window may be rotated:

Possible values:

The rotation can also be changed dynamically with MOD+(left) and MOD+ (right).

Note that scrcpy manages 3 different rotations:

To disable controls (everything which can interact with the device: input keys, mouse events, drag&drop files):

If several displays are available, it is possible to select the display to mirror:

The list of display ids can be retrieved by:

The secondary display may only be controlled if the device runs at least Android 10 (otherwise it is mirrored as read-only).

To prevent the device from sleeping after a delay when the device is plugged in:

The initial state is restored when scrcpy is closed.

It is possible to turn the device screen off while mirroring on start with a command-line option:

Or by pressing MOD+o at any time.

To turn it back on, press MOD+Shift+o.

On Android, the POWER button always turns the screen on. For convenience, if POWER is sent via scrcpy (via right-click or MOD+p), it will force to turn the screen off after a small delay (on a best effort basis). The physical POWER button will still cause the screen to be turned on.

It can also be useful to prevent the device from sleeping:

To turn the device screen off when closing scrcpy:

By default, on start, the device is powered on.

To prevent this behavior:

For presentations, it may be useful to show physical touches (on the physical device).

Android provides this feature in Developers options.

Scrcpy provides an option to enable this feature on start and restore the initial value on exit:

Note that it only shows physical touches (by a finger on the device).

By default, scrcpy does not prevent the screensaver from running on the computer.

To disable it:

Press MOD+r to switch between portrait and landscape modes.

Note that it rotates only if the application in foreground supports the requested orientation.

Any time the Android clipboard changes, it is automatically synchronized to the computer clipboard.

Any Ctrl shortcut is forwarded to the device. In particular:

This typically works as you expect.

The actual behavior depends on the active application though. For example, Termux sends SIGINT on Ctrl+c instead, and K-9 Mailcomposes a new message.

To copy, cut and paste in such cases (but only supported on Android >= 7):

In addition, MOD+Shift+v injects the computer clipboard text as a sequence of key events. This is useful when the component does not accept text pasting (for example in Termux), but it can break non-ASCII content.

WARNING: Pasting the computer clipboard to the device (either via Ctrl+v or MOD+v) copies the content into the Android clipboard. As a consequence, any Android application could read its content. You should avoid pasting sensitive content (like passwords) that way.

Some Android devices do not behave as expected when setting the device clipboard programmatically. An option --legacy-paste is provided to change the behavior of Ctrl+v and MOD+v so that they also inject the computer clipboard text as a sequence of key events (the same way as MOD+Shift+v).

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

More precisely, hold down Ctrl while pressing the left-click button. Until the left-click button is released, all mouse movements scale and rotate the content (if supported by the app) relative to the center of the screen.

Technically, scrcpy generates additional touch events from a “virtual finger” at a location inverted through the center of the screen.

By default, scrcpy uses Android key or text injection: it works everywhere, but is limited to ASCII.

However, it only works if the device is connected via USB.

To enable this mode:

In this mode, raw key events (scancodes) are sent to the device, independently of the host key mapping. Therefore, if your keyboard layout does not match, it must be configured on the Android device, in Settings → System → Languages and input → Physical keyboard.

This settings page can be started directly:

However, the option is only available when the HID keyboard is enabled (or when a physical keyboard is connected).

Similarly to the physical keyboard simulation, it is possible to simulate a physical mouse. Likewise, it only works if the device is connected by USB.

By default, scrcpy uses Android mouse events injection with absolute coordinates. By simulating a physical mouse, a mouse pointer appears on the Android device, and relative mouse motion, clicks and scrolls are injected.

To enable this mode:

When this mode is enabled, the computer mouse is “captured” (the mouse pointer disappears from the computer and appears on the Android device instead).

Special capture keys, either Alt or Super, toggle (disable or enable) the mouse capture. Use one of them to give the control of the mouse back to the computer.

It is possible to run scrcpy with only physical keyboard and mouse simulation (HID), as if the computer keyboard and mouse were plugged directly to the device via an OTG cable.

In this mode, adb (USB debugging) is not necessary, and mirroring is disabled.

To enable OTG mode:

It is possible to enable only HID keyboard or HID mouse:

Like --hid-keyboard and --hid-mouse, it only works if the device is connected by USB.

By default, letters are injected using key events, so that the keyboard behaves as expected in games (typically for WASD keys).

But this may cause issues. If you encounter such a problem, you can avoid it by:

(but this will break keyboard behavior in games)

On the contrary, you could force to always inject raw key events:

These options have no effect on HID keyboard (all key events are sent as scancodes in this mode).

By default, holding a key down generates repeated key events. This can cause performance problems in some games, where these events are useless anyway.

To avoid forwarding repeated key events:

This option has no effect on HID keyboard (key repeat is handled by Android directly in this mode).

By default, right-click triggers BACK (or POWER on) and middle-click triggers HOME. To disable these shortcuts and forward the clicks to the device instead:

To install an APK, drag & drop an APK file (ending with .apk) to the scrcpywindow.

There is no visual feedback, a log is printed to the console.

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

There is no visual feedback, a log is printed to the console.

The target directory can be changed on start:

Also see issue #14.

In the following list, MOD is the shortcut modifier. By default, it’s (left) Alt or (left) Super.

It can be changed using --shortcut-mod. Possible keys are lctrl, rctrl, lalt, ralt, lsuper and rsuper. For example:

¹Double-click on black borders to remove them.
²Right-click turns the screen on if it was off, presses BACK otherwise.
³4th and 5th mouse buttons, if your mouse has them.
⁴For react-native apps in development, MENU triggers development menu.
⁵Only on Android >= 7.

Shortcuts with repeated keys are executed by releasing and pressing the key a second time. For example, to execute “Expand settings panel”:

All Ctrl+key shortcuts are forwarded to the device, so they are handled by the active application.

To use a specific adb binary, configure its path in the environment variable ADB:

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

To override the icon, configure its path in SCRCPY_ICON_PATH.

For general questions or discussions, you can also use:

Only this README file is guaranteed to be up-to-date.

source


CyberTelugu

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top

Adblock Detected

Please consider supporting us by disabling your ad blocker

Refresh Page