TuesdayTooling: scrcpy

Record, display, interact with your Android phone, over USB from your desktop!

So what is it?

scrcpy is a very cool tool to display and control an Android 5 or greater device. I discovered this project thanks to OMG Ubuntu back in November last year and while I gave it a test run back then, I never truly appreciated scrcpy at the time as I thought it was fiddly. The problem was with the user (me) not the tool, which makes me the tool. Thankfully OMG Ubuntu released a fresh blog post with updated information about scrcpy so I had to have another go, and I was right to!

So I still don't know what scrcpy does Les!

"This application (scrcpy) provides display and control of Android devices connected on USB (or over TCP/IP). It does not require any root access. It works on GNU/Linux, Windows and macOS."

Created by Genymobile, the scrcpy project can be seen on GitHub and it is well worth a read.

The tool focuses on

  • lightness (native, displays only the device screen)
  • performance (30~60fps)
  • quality (1920×1080 or above)
  • low latency (35~70ms)
  • low startup time (~1 second to display the first image)
  • non-intrusiveness (nothing is left installed on the device)

Hi reader!

I never put my blog posts behind paywall or pop ups because quite frankly that is annoying and prevents anyone from accessing the content. I will always keep my blog content free of charge. But I do ask that if you are able and willing, that you buy me a "coffee" as it helps me to pay for hosting this blog, and to buy stuff to hack from Poundshops / Dollar Stores / Aliexpress which are used in free projects and reviews on this blog. It is You dear reader who make this possible, and I am immensely grateful for your support.

Thanks!

So how do I install it?



Linux (Debian testing / SID) and Ubuntu 18.04 >

sudo apt install scrcpy

macOSX

You will need to install Homebrew first.

brew install scrcpy

Windows 10

Download the ZIP file, extract the contents and open a Command Prompt in the extracted folder.

scrcpy.exe

So how do I use it?

To use scrcpy we need to enable USB debugging on out phone, this enables scrcpy to communicate with the device.

We need to enable Developer Options on our Android device.

Go to Settings >> About Phone



Click on build number until the device tells you that you have Developer Access!



Next go to System >> Advanced



Now go to Developer options and scroll down to USB Debugging and make sure that it is enabled.



Plug in your phone to the computer using a good quality USB lead.

Open a Terminal / Command Prompt and run the command scrcpy

You may be asked to allow your computer to connect to the device, this is normal the first time that we run scrcpy.



Right now we can use our phone from our computer! Try it!

Open a browser and go to a website. Write an email, control the camera, all via your keyboard and mouse!

So is that it?

Nope!

The first issue that I faced was that the application window did not rotate when I turned the device on its side. This is a pain, but fear not!

Screen Rotation



ctrl + ← will rotate the application window 90° counterclockwise.

ctrl + → to rotate display 90° clockwise.

Or we can also use an argument / flag when we call the scrcpy command to set the rotation.

scrcpy --lock-video-orientation 0 is portrait

scrcpy --lock-video-orientation 1 is 90° counterclockwise

scrcpy --lock-video-orientation 2 is 180° upside down portrait

scrcpy --lock-video-orientation 3 is 90° clockwise

Resize the application window

You can handily resize the application window, giving us a faster performing experience, or just if our monitor is tiny!

scrcpy -m 512

This code will set the maximum height of the window to 512 pixels. The width is calculated based on the ratio.

Recording your phone screen.

Yes this was recorded directly from my phone!

This is a handy feature when making screencasts / videos explaining how to perform a task on a phone.

scrcpy --record file.mp4

Show touches



Running a presentation / screencast and want to show where you are pressing?

Fear not! Run this command and you will see where your fingers are on the screen.

scrcpy --show-touches

Copy paste between devices!

Want to copy something from the device to your computer, or the other way? You can!

  • Ctrl+c copies the device clipboard to the computer clipboard;
  • Ctrl+Shift+v copies the computer clipboard to the device clipboard;
  • Ctrl+v pastes the computer clipboard as a sequence of text events (but breaks non-ASCII characters).

Install software

Got an APK file that you would like to install?

Drag and drop the file from your computer to the application window and it auto installs. No feedback, but it just does it. You will need to enable install unknown apps to make this work.

Last minute update! Wireless control / display!

FXBOY4EVA asks...

So I tried it, and wow it was easy.

So here is how to do it!

  • Install adb for your operating system, I am using Ubuntu 20.04 and so I typed sudo apt install adb
  • Connect your Android device to the same network as your computer.
  • Get your device IP address (in Settings → About phone → Status)
  • Plug in your Android device to the computer using a USB lead.
  • Enable adb over TCP/IP on your device: adb tcpip 5555
  • Unplug your Android device from the computer.
  • Connect to your Androind device: adb connect DEVICE_IP:5555 replace DEVICE_IP with with the Android devices IP address. For example mine was adb connect 192.168.0.7:5555
  • On your computer run scrcpy and it will connect to your Android device.