Scrcpy controls Android phone with computer (supports windows / Mac OS / Linux)

Time:2020-9-19

1、 Introduction to scrcpy

Note: the spelling is scrcpy, a non Python crawler framework.

Scrcpy can be debugged through the way of ADB to put the phone screen on the computer, and can control your Android device through the computer. It can be connected via USB (required for the first time) or via WiFi (via TCP / IP, similar to airdrop screen), and does not require any root privileges and does not need to install any programs in the phone. Scrcpy is suitable for GNU / Linux, windows and MacOS.

It has some characteristics

  1. Brightness (native, display device screen only)
  2. Performance (30 ~ 60fps)
  3. Mass (1920 × 1080 or above)
  4. Low latency (35 ~ 70ms)
  5. Short startup time (display the first image for about 1 second)
  6. Non intrusive (nothing is installed on the device)

Scrcpy’s project website on GitHub: https://github.com/Genymobile/scrcpy |Client download address( https://github.com/Genymobile/scrcpy/releases )。

Genymobile is a French company specializing in Android simulation and developer services. Genymotion, as you know it, is one of its products.

2、 Requirements for using scrcpy

  1. Android devices require at least API 21 (Android version 5.0 or above)
  2. Make sure that ADB debugging is enabled on your device

On some devices, you also need to enable other options to control it using the keyboard and mouse.

3、 Connect using USB

This method is recommended and relatively more fluent.

When the mobile phone is connected to the PC via USB, the first connection will pop up whether to trust the computer. Click always trust.
functionadb usbCheck whether the connection is successfulscrcpyThat’s fine.

D:\xushanxiang\scrcpy-win64-v1.10>adb usb
restarting in USB mode

You can also add D: (xushanxiang) scrcpy-win64-v1.10 to the system environment variable.

If there are multiple devices, you need to specify the serial number, which can be obtained from the ADB devices, such as:

adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully

6a86de95 device

scrcpy -s 6a86de95

View the connected device command: ADB devices. If device is displayed, it means it is connected; if offline is displayed, it is offline.

If it is MacOS, executescrcpyAfter that, the following contents will appear, and the current real-time interface of the mobile phone (screen projection) will pop up, and you can also operate the mobile phone on the computer interface.

~ scrcpy
* daemon not running; starting now at tcp:5037
* daemon started successfully
/usr/local/Cellar/scrcpy/1.8/share/scrcpy/scrcpy-serv....jar: 1 file pushed. 1.0 MB/s (19850 bytes in 0.019s)
2019-11-28 10:31:45.315 scrcpy[4701:62681] INFO: Initial texture: 1080x1920

4、 Use wireless connection

Please refer to the official document: open source project – scrcpy now works wirelessly

–https://www.genymotion.com/blog/open-source-project-scrcpy-now-works-wirelessly/

This connection method is more convenient and fast. If the broadband speed is high, the use effect is better, and the use method is also very simple. The steps are as follows:

  1. Make sure your PC and phone are on the same WiFi
  2. The mobile phone is connected to PC through USB
  3. Run on PCADB TCPIP service portFor example, the port is 5555
  4. Unplug the USB connection from the phone
  5. Run on PCMobile phone IP: service port
  6. Run as usualscrcpyRelated commands
  7. To switch back to USB mode:adb usb

The mobile phone IP can be viewed through the status information of the mobile phone or by logging in to the router, generally starting with 192.168.

In this way, the screen of the mobile phone pops up, and the screen of the mobile phone is successful!

As expected, the performance is different from USB, and the default scrcpy bit rate is 8mbps, which may be too much for a Wi Fi connection.

Depending on the usage, reducing bit rate and resolution may be a good compromise.

scrcpy –bit-rate 2M –max-size 800

Scrcpy – B2M – M800

5、 Some scrcpy commands

1. Start scrcpy

scrcpy

2. If you have multiple devices, you need to specify the serial number, which can be obtained from the ADB devices

scrcpy -s 6a86de95

3. Set port

scrcpy -p 27184

4. View help

scrcpy --help

5. Set code rate (default 8m)

scrcpy -b 8M

6. Limited screen size

scrcpy -m 1024

7. Crop projection screen (length: width: offset X: offset y)

scrcpy -c 800:800:0:0

8. Screen casting and recording

scrcpy -r file.mp4

9. Record screen without screen projection

scrcpy -Nr file.mp4

10. The trackball is displayed when the finger touches it

scrcpy -t

11. Display version information

scrcpy -v

12. Close device screen
You can close the device screen when you start mirroring using the command line option:

scrcpy --turn-screen-off
scrcpy -S

Or press at any timeCtrl + o。 To reopen it, pressPower key(orCtrl + p)。

6、 Common shortcut keys of scrcpy

Action Shortcut Shortcut (macOS)
Switch full screen mode Ctrl+f Cmd+f
Adjust the window to 1:1 (perfect pixels) Ctrl+g Cmd+g
Size the window to remove the black border Ctrl+x | Double-click¹ Cmd+x | Double-click¹
Return to home Ctrl+h | Middle-click Ctrl+h | Middle-click
return Ctrl+b | Right-click² Cmd+b | Right-click²
Click on APP_SWITCH Ctrl+s Cmd+s
Click on the menu Ctrl+m Ctrl+m
Adjust the volume Ctrl+ (up) Cmd+ (up)
Adjust the volume Ctrl+ (down) Cmd+ (down)
Click the phone power supply Ctrl+p Cmd+p
Power on Right-click² Right-click²
Close device screen (keep mirror) Ctrl+o Cmd+o
Expand notification panel Ctrl+n Cmd+n
Collapse notification panel Ctrl+Shift+n Cmd+Shift+n
Copy device clipboard to computer Ctrl+c Cmd+c
Paste computer clipboard to device Ctrl+v Cmd+v
Copy computer clipboard to device Ctrl+Shift+v Cmd+Shift+v
Enable / disable FPS counter (on standard output) Ctrl+i Cmd+i

Dle double click the black border to delete it.
If it is turned off, right-click to open the screen, otherwise press back.

7、 Conclusion

In this way, we use two ways (USB connection and WiFi connection) to use scrcpy. For other methods, please refer to readme( https://github.com/Genymobile/scrcpy#features )For example, you can drag and drop the APK directly to install, record the screen of mobile phone, etc.

Original text: https://xushanxiang.com/2019/11/android-scrcpy.html