Mirror Android Screen to PC using scrcpy - GeeksforGeeks

01 Oct, 2020
scrcpy is a free and open-source Android screen mirroring application. It is a very lightweight application that provides display and control of Android devices connected over USB or TCP. It doesn’t require any root access. In this article, we are going to see how can we mirror the android device’s screen using it.
Android 5.0 or later.
A USB cable.
Enable USB debugging.
A zip file with all dependencies is available for windows. You can download it here. adb tool is also included in this package, so, you don’t have to download it separately. Extract this folder in the current working directory.
On Linux, it can be installed directly using the standard package manager.
For example, on Debian based OS, run the following command to install it:
$ sudo apt-get install scrcpy 
It can also be downloaded using snap.
This application is also available in Homebrew. Run the following command to install it.
brew install scrcpy
Note: USB Debugging mode needs to be turned on before connecting the android device in any mode.
To communicate with the android devices, scrcpy uses the Android debugging tool (adb). adb can connect to the device over TCP/IP. To connect wirelessly, connect the android device with the PC using USB first. Then, run the following command to enable TCP/IP on your device. The port 5555 is used here. You can use any port number you want.
adb tcpip 5555
Now, disconnect the android device from the PC and run the following command to connect with the device over TCP/IP. Replace IP_ADDR  with the IP Address of your device.
adb connect IP_ADDR:5555
Now, run scrcpy as usual and it will start displaying your device’s screen wirelessly.
To connect the device using a USB Cable, You just need to connect the device to the PC and run scrcpy on command prompt:
scrcpy
After you run it, it will start displaying the device’s screen.
Running scrcpy
There are many manipulations that can be done on mobile using scrcpy. Some of them are listed below with an example. Type the following commands in the command prompt.
This tool allows users to connect multiple devices simultaneously. You just need to follow these simple steps to make it work. First, turn USB debugging on for all the devices and connect them to the PC. Then, list all the devices which are recognized by adb by running the following command.
adb devices
Output of adb devices
Now, for each device listed in the output, copy its serial number and run the following command. Replace SERIAL_NUM with the serial number of the device.
scrcpy --serial SERIAL_NUM
It will display all the devices on the screen.
Two devices connected simultaneously
You can also mirror the device’s screen at a lower resolution to increase performance.
scrcpy --max-size 720 
Running scrcpy –max-size 640
It preserves the aspect ratio of the screen.
 You can also change the frame rate of the captured screen.
scrcpy --max-fps 10 
 Sometimes, you only need to display a part of the screen, so, you can so that with this feature.
scrcpy --crop 1224:1440:0:0 
Running scrcpy –crop 1080:720:0:0
 You can also record the screen while mirroring.
scrcpy --record myrecording.mp4 
 You can start the app directly in full-screen mode.
scrcpy --fullscreen 
Running scrcpy –fullscreen
Sometimes, you need to show the physical touches. This feature will help you in that case.
scrcpy --show-touches 
 Prevent the device from sleeping after some delay.
scrcpy --stay-awake 
Android
TechTips
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create and Add Data to SQLite Database in Android?
Broadcast Receiver in Android With Example
Resource Raw Folder in Android Studio
CardView in Android With Example
Services in Android with Example
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
How to Run a Python Script using Docker?
Setting up the environment in Java
How to Add External JAR File to an IntelliJ IDEA Project?