LinuxCommandLibrary

scrcpy

Display and control Android devices

TLDR

Display a mirror of a connected device

$ scrcpy
copy

Turn the device screen off and prevent it from sleeping while mirroring
$ scrcpy [[-S|--turn-screen-off]] [[-w|--stay-awake]]
copy

Display a mirror of a specific device based on its ID or IP address (find it under the adb devices command)
$ scrcpy [[-s|--serial]] [0123456789abcdef|192.168.0.1:5555]
copy

Start display in fullscreen mode
$ scrcpy [[-f|--fullscreen]]
copy

Show touches on physical device
$ scrcpy [[-t|--show-touches]]
copy

Record display screen
$ scrcpy [[-r|--record]] [path/to/file.mp4]
copy

Specify the target directory for pushing files to device by drag and drop (non-APK)
$ scrcpy --push-target [path/to/directory]
copy

SYNOPSIS

scrcpy [options]

PARAMETERS

--always-on-top
    Keep the scrcpy window always on top of other windows.

-b , --bit-rate
    Set the video bit-rate in bits per second (e.g., 2M for 2 megabits). Default is 8M.

--crop :::
    Crop the device screen to a specific region. Useful for specific applications or resolutions.

-d, --select-usb
    Select a USB device. Useful when multiple devices are connected.

--display
    Specify the display ID to mirror (e.g., 0 for default, 1 for secondary display).

--disable-screensaver
    Disable the screensaver on the computer while scrcpy is running.

-e, --select-tcpip
    Select a TCP/IP device. Useful when multiple devices are connected (USB and TCP/IP).

-f, --fullscreen
    Start the scrcpy window in fullscreen mode.

-h, --help
    Show the help message and exit.

--max-fps
    Limit the capture frame rate (e.g., 30 for 30 FPS). Useful for lower-end PCs or network constraints.

--max-size
    Limit the video dimension (width or height). The other dimension is computed to maintain aspect ratio.

-n, --no-control
    Disable device control, providing mirroring only without keyboard/mouse input.

--no-audio
    Disable audio forwarding. Requires Android 11+ and scrcpy v1.23+ for audio forwarding to be available.

--no-display
    Do not display the device window. Useful for background screen recording without showing the window.

-r , --record
    Record the mirrored screen to an MP4 file specified by .

-s , --serial
    Specify the device by its serial number, useful for managing multiple devices.

-S, --turn-screen-off
    Turn the device screen off when mirroring starts and turn it back on when scrcpy exits.

-M, --show-touches
    Show physical touches on the device screen, useful for demonstrations or debugging.

-v, --version
    Show the scrcpy version and exit.

--window-borderless
    Disable window decorations (title bar, borders).

--window-height
    Set the initial height of the scrcpy window.

--window-title
    Set the title of the scrcpy window.

--window-width
    Set the initial width of the scrcpy window.

--window-x
    Set the initial X position of the scrcpy window on the screen.

--window-y
    Set the initial Y position of the scrcpy window on the screen.

DESCRIPTION


scrcpy (screen copy) is a free and open-source application that allows you to display and control your Android device from your Linux desktop. It offers high performance, low latency, and high resolution by connecting directly to the device's screen and input. The application requires no root access on the Android device and works by executing an adb server on the computer and a small client on the Android device. This enables a seamless mirroring and control experience, whether connected via USB or wirelessly (through adb over TCP/IP). It's designed to be lightweight and fast, making it an excellent tool for developers, gamers, and anyone needing to interact with their Android device without physically touching it. Key features include screen mirroring, keyboard and mouse input, screen recording, and various customization options for resolution, bit-rate, and display settings.

CAVEATS

ADB Requirement: scrcpy relies heavily on the Android Debug Bridge (ADB). You must have ADB installed and configured correctly on your Linux system, and your Android device must have USB debugging enabled.
Performance: While generally high-performing, the actual latency and quality can vary based on your device's processing power, USB cable quality, and network conditions (for wireless connections).
Audio Forwarding: Audio forwarding is a relatively newer feature (introduced in scrcpy v1.23) and requires Android 11 or higher. Its stability and performance can vary.
File Transfer: scrcpy itself does not provide direct file transfer capabilities. For transferring files, you still need to use adb push or adb pull commands.

KEYBOARD SHORTCUTS


Ctrl+f: Toggle fullscreen.
Ctrl+g: Resize window to 1:1 pixel-perfect (may be very large).
Ctrl+x / double-click on black borders: Resize window to remove black borders.
Ctrl+h: Simulate "Home" button.
Ctrl+b: Simulate "Back" button.
Ctrl+m: Simulate "Menu" button.
Ctrl+w: Turn device screen on/off.
Ctrl+o: Turn device screen on.
Ctrl+p: Power off device (Android 9+).
Ctrl+Shift+s: Take a screenshot.
Ctrl+Shift+z: Inject SCRCPY_TOGGLE_AUDIO_PLAYBACK (if audio is enabled).
Ctrl+Shift+f: Open the file explorer (if on Android 10+).
Ctrl+c: Copy device clipboard to computer.
Ctrl+v: Paste computer clipboard to device.
Drag & drop APK: Install an APK file onto the device (on Android 7+).
Right-click: Simulate "Back" button.

CONNECTING WIRELESSLY


1. Connect your Android device to your computer via USB.
2. Enable ADB over TCP/IP on your device: adb tcpip 5555 (you can choose any available port).
3. Disconnect the USB cable from your device.
4. Connect to your device wirelessly: adb connect <device_ip_address>:5555.
5. Run scrcpy: scrcpy

BASIC ADB SETUP


To use scrcpy, you need to enable USB debugging on your Android device and have ADB installed on your computer.
1. On your Android device, go to Settings > About phone and tap "Build number" seven times to enable Developer options.
2. Go to Settings > System > Developer options and enable "USB debugging".
3. Connect your device to your computer via USB.
4. On your computer, verify connection with adb devices. You might need to accept a prompt on your phone for "Allow USB debugging?" from your computer's RSA key fingerprint.

HISTORY


scrcpy was developed by Genymobile, the company behind the Android emulator Genymotion. It was first publicly released in March 2018. The project's primary goal was to provide a free, open-source, lightweight, and high-performance solution for mirroring and controlling Android devices. It quickly gained popularity due to its simplicity, efficiency, and lack of root requirements, becoming a go-to tool for developers and general users alike. Constant development has added features like audio forwarding, multiple display support, and improved performance.

SEE ALSO

adb(1), ffmpeg(1), ffplay(1)

Copied to clipboard