Scrcpy, control your Android device from the Ubuntu desktop

about scrcpy installation

In the next article we are going to take a look at scrcpy. It is a free and open source application that will allow us to view and control Android devices connected via USB or wirelessly, but with a lower performance. Communication between the server and the client is done through adb. The server transmits the H.264 video from the Android screen to the client for decoding and display, no buffering to minimize latency. Mouse and keyboard events are captured and transmitted to the server.

Scrcpy tries to be light, offering performance and quality. It offers 30 ~ 60 FPS with a resolution that we can configure. To make it work android version will have to be 5.0 minimum and adb debugging must be enabled on the Android device. Does not require root access.

Scrcpy general features

  • We can control Android devices from the desktop, with a mouse and keyboard.
  • It can work via USB or WiFi, although from Wifi it decreases the performance.
  • Allows record android screen.
  • Possible limit the width and height of the resolution of Android.
  • It can control the phone using the keys of the computer.
  • Allows change video bit rate.
  • The application can be launch directly to full screen (Ctrl + f).
  • For presentations, the application can display the physical touches on the android device.
  • We will be able install APK by dragging and dropping them in the scrcpy window, or insert into device by dragging and dropping a non-APK file.
  • Audio forwarding does not work due to an Android limitation.

These are just some of the features, you can see all of them in more detail in the project GitHub page.

Install scrcpy on Ubuntu

Although this program can be installed on Windows, MacOS or Gnu / Linux, for this example we will see the installation on Ubuntu 18.04. The official installation instructions can be found on their GitHub page.

To start we will install the necessary dependencies to compile and run the application on Debian, Ubuntu and Linux Mint. We open a terminal (Ctrl + Alt + T) and write:

dependencies to install scrcpy

sudo apt install adb ffmpeg libsdl2-2.0.0 make gcc pkg-config meson ninja-build libavcodec-dev libavformat-dev libavutil-dev libsdl2-dev

Unlike the official build instructions, OpenJDK is not included because we are going to use the precompiled scrcpy-server .jar, to make things easier.

Download and install the .jar server

scrcpy .jar server download page

We continue downloading the latest scrcpy-server-v * .jar from the versions page of the application. For this example I will save the downloaded file in my home folder.

move servicor scrcpy local folder share

We continue creating the folder / usr / local / share / scrcpy to copy the file to her scrcpy-server-v * .jar from home folder:

sudo mkdir -p /usr/local/share/scrcpy

sudo mv scrcpy-server-v*.jar /usr/local/share/scrcpy/scrcpy-server.jar

Download the latest version of the application

download scrcpy file .tar.gz

For this example I will download the .tar.gz file which can be found on the launches page of the application. Then I will extract it in the home directory, in a folder called scrcpy. Remove the version number from the scrcpy folder name, for higher comfort.

Compile and install

install scrcpy

Starting from the folder home, First we are going to set the server path with the server_path variable to the path where we copy the scrcpy-server.jar:

server_path='/usr/local/share/scrcpy/scrcpy-server.jar'

To compile scrcpy we are going to go to the scrcpy folder:

cd scrcpy

Now we will compile and install the application:

meson build --buildtype release --strip -Db_lto=true -Dbuild_server=false -Doverride_server_path="${server_path}"

cd build

ninja

sudo ninja install

After this if you want, you can now delete the scrcpy folder from the home directory.

Control or record your Android device

To make it work properly we will need a mobile device with at least Android 5.0. In addition, we will have to have enabled the adb debugging on Android device. On some devices, you may also need to enable 'USB debugging' option.

Start scrcpy

To use scrcpy, connect your Android device via USB first. Then run the application in a terminal (Ctrl + Alt + T):

scrcpy running on the phone

scrcpy

When you run scrcpy for the first time, make sure the phone screen is unlocked to authorize the app with the prompt that will appear on the phone.

Record Android screen

You can easily record Android screen while using the phone from the desktop running the application with the option -record. After it you must indicate a name for the file and an extension (mkv or mp4) as you can see below:

Phone recording with scrcpy

scrcpy --record file.mp4

Uninstall scrcpy

If you have installed the application following the instructions in this article, you can remove it by executing these two commands:

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

To find out how control Android device wirelessly or more in detail from desktop, you can follow the Instructions from the project's GitHub page.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   DigitOptic Technology Services said

    Excellent Contribution !!!

  2.   rafael said

    thanks for the tutorial but when finishing the installation and running scrcpy nothing happens, it doesn't run. what could it be, greetings

    1.    Damien Amoedo said

      Do you have adb debugging enabled on Android device?

  3.   Tesseract said

    This appears to me and I can't run ninja

    app / meson.build: 28: 4: ERROR: Native dependency 'libavformat' not found

    A full log can be found at /home/teseract/scrcpy/build/meson-logs/meson-log.txt

    1.    Damien Amoedo said

      First of all, be careful when copying the commands from the article (for the double quotes and stuff) or
      try sudo apt-get install libavformat-dev and run it again. If you don't look in the program's documentation.