Control Android devices from desktop with scrcpy (Ubuntu, Fedora, Debian, Linux Mint installation)

script Is a free open source application for displaying and controlling Android devices connected from a Linux, Windows or macOS desktop via a USB (or wireless connection, but lower performance).
It requires at least Android 5.0, and adb debugging must be enabled on the Android device. No root access is required. scrcpy focuses on brightness, performance and quality, offering 30 ~ 60 FPS with a resolution of 1920×1080 or higher. It also has lower latency, between 70 and 100 milliseconds. I must say that the performance of scrcpy surprised me the first time I tried it, it almost felt like I was holding an Android device in my hand, rather than using it remotely from a Linux desktop.
The communication between the server (Android device in this case) and the client (desktop computer) is through a socket on the adb tunnel. The server streams H.264 video of the device screen and then passes it to the client to decode and display it without buffering to minimize latency. Mouse and keyboard events are captured and transmitted to the server, which injects them into the Android device.
feature:

  • Control Android devices from desktop (using mouse and keyboard) running Linux, Windows or macOS
  • Works over USB or WiFi (although performance decreases when used over WiFi)
  • Allow recording Android screen while mirroring
  • Can limit the width and height of the Android mirror resolution
  • Allows changing the video bit rate
  • Device screen can be cropped
  • Can mirror multiple devices at the same time
  • The scrcpy application can be launched directly in full screen mode
  • For presentations, scrcpy can show the physical touch on an Android device (only the physical touch of a finger on the device!)
  • Install the APK by dragging and dropping it into the scrcpy window, or push the file to the device /sdcard Non-APK files by drag and drop
  • Read-only mode to disable interaction using input keys, mouse events, and drag and drop operations

Audio forwarding does not work, which is a limitation of the Android open attachment protocol.
If you feel that the quality is not the best (for example, using fonts or gradient colors), it is most likely because the screen is down. Switch your Android device to landscape mode and run scrcpy in full screen mode (Ctrl + F) For better quality.
It’s also worth noting that the “scrcpy” name comes from “Screen Copy”. That should be easier to remember ?️.scrcpy can be downloaded from https://github.com/Genymobile/scrcpyDevelopers provide pre-compiled binaries for Microsoft Windows and Homebrew packages for macOS. Have an Arch Linux AUR Bag and a Gentoo Yi Jian Yes.
Related to Android:

  • Anbox: How to easily install Google Play Store and enable ARM (libhoudini) support
  • Use GSConnect to integrate your Android phone with Gnome Shell without KDE dependencies

Install scrcpy on Ubuntu, Fedora, Debian or Linux Mint

Scrcpy control Android from Ubuntu, Fedora or Debian

I found the official script set up The instructions for using Linux are a bit confusing, so I decided to try to make them easier. There is a new unofficial scrcpy snap The package is available in the Snap store, but it is not available on my Ubuntu 18.10 desktop, so it may still require some work. The scrcpy package is now available, so you can use the scrcpy snap package to simplify the installation of your application.
I tried the following steps and did my own codec on Ubuntu 18.10, 18.04 and Fedora 29. Since Ubuntu is based on Debian and Linux Mint is on Ubuntu, it should also run on Debian or Ubuntu.1 based Linux distributions as well as other Linux distributions. . Install the dependencies required to build and run scrcpy on Debian, Ubuntu and Linux Mint or Fedora.

  • Debian, Ubuntu or Linux Mint:
sudo apt install adb ffmpeg libsdl2-2.0.0 make gcc pkg-config meson ninja-build libavcodec-dev libavformat-dev libavutil-dev libsdl2-dev
  • Fedora (first command to enable RPMFusion repository-skip it if it is enabled on your Fedora computer):
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm

sudo dnf install android-tools ffmpeg SDL2-devel ffms2-devel meson gcc make

It’s worth noting that Meson 0.37 or higher is required (if you are using Ubuntu 16.04, enable the Backports repository to install a newer Meson version). Contrary to the official build instructions, OpenJDK is not included in my guide because it uses a precompiled scrcpy-server jar to make things easier.
These are just distribution-specific instructions, so if you know how to install these dependencies for some other Linux distributions (which may have different names depending on the Linux distribution you are using), the other steps should be the same. Download and install the scrcpy server jar.
Download the latest version scrcpy-server-v*.jar From Application release pageAnd put it in your home folder. If the file does not have .jar Extension, rename it and add it yourself.
Next, install it to /usr/local/bin (Even if it will be installed in /usr/local/share/scrcpyAnd for some reason scrcpy searches in /usr/local/bin):

sudo install scrcpy-server-v*.jar /usr/local/bin/scrcpy-server.jar

3. Download the latest scrcpy version source code and unzip it into your home folder.Download scrcpy source code ( .tar.gz (For example, archive from the application release page), and then unzip it into a folder in your home directory scrcpy (Remove the version number from the scrcpy folder name-this makes these instructions easier to use in future scrcpy versions).
The home folder should now have a file named scrcpy-server-v*.jar (E.g. scrcpy-server-v1.11.jar (For scrcpy v1.11) and one named scrcpy.4. Generate and install scrcpy.
To build scrcpy, we will navigate to the scrcpy folder, build the application and install it:

cd scrcpy

meson build --buildtype release --strip -Db_lto=true  -Dprebuilt_server=../scrcpy-server-v1.11.jar

cd build

ninja

sudo ninja install

If you want to install another scrcpy version, please replace scrcpy-server-v1.11.jar Get the exact file name from the second command, which contains the version you want to install.
You can now delete the scrcpy folder from your home directory as needed.

How to use scrcpy on Linux to control an Android device (or record its screen) from a Linux desktop

I already mentioned this at the beginning of the article, but I think I should say it again. You need an Android 5.0 or higher device to control it from the desktop using scrcpy. Also, make sure to enable ADB commissioning On your Android device. On some devices, you may need to enable additional “USB debugging (security settings)” Option So that you can control your Android device from your desktop computer. To use scrcpy, connect your Android device to your computer via USB and run scrcpy in a terminal:

scrcpy

If you are not using adb to authorize your current computer with your Android device, when running scrcpy for the first time, make sure your Android device screen is unlocked and you have authorized scrcpy (click OK When asking for authorization on an Android device)!
It’s also worth noting that on computers I haven’t run adb before, I have to run scrcpy 3 times until it works (it may not have waited enough time to authorize), so you might want to use it if you ca n’t , Also do the following:

[email protected]:~$ scrcpy
* daemon not running. starting it now on port 5037 *
free(): invalid next size (fast)
ADB server didn't ACK
* failed to start daemon *
adb: error: connect failed: cannot connect to daemon
ERROR: "adb push" returned with value 1

[email protected]:~$ scrcpy
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
adb: error: connect failed: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
ERROR: "adb push" returned with value 1

[email protected]:~$ scrcpy
[100%] /data/local/tmp/scrcpy-server.jar
INFO: Initial texture: 1440x2560

Want to record your Android screen while controlling your Android device using your desktop (using your keyboard and mouse)? Use to run scrcpy --record Then the file name to be recorded, the extension is mkv or mp4. E.g. :

scrcpy --record file.mp4

You may be wondering how to return to the previous screen when controlling an Android device from your desktop, go to the home screen or use the app switcher, for devices with physical keys-you can use shortcut:

  • Rat right-click Either Ctrl + b (Either Ctrl + Backspace)return
  • Rat middle-click Either Ctrl + h (Or Home Button)
  • Ctrl + s For application switcher

For information on how to wirelessly control your Android device from your desktop, see Detailed description On the application project page. See also scrcpy page For more advanced usage, such as reducing the size of the mirrored screen, changing the bit rate, cropping the screen or running multiple scrcpy instances with multiple Android devices.

How to uninstall scrcpy (install from source)

Users who want to remove the installed scrcpy from the source (using the instructions in this article) can run the following two commands:

sudo rm /usr/local/share/scrcpy/scrcpy-server.jar
sudo rm /usr/local/bin/scrcpy-server.jar
sudo rm /usr/local/bin/scrcpy

Source

Related Posts