Xiang Ruan's Homepage

Anything I want to share with this world.

scrcpy

scrcpy is a tool to mirror and control android phone from PC. scrcpy is cross-platform software which is able to run at Windows, Mac and Linux

Installation (1)

  • clone from https://github.com/Genymobile/scrcpy

    git clone https://github.com/Genymobile/scrcpy scrcpy
    
  • install related packages

    # runtime dependencies
    sudo apt install ffmpeg libsdl2-2.0-0
    # client build dependencies
    sudo apt install adb make gcc git pkg-config meson ninja-build \
    	    libavcodec-dev libavformat-dev libavutil-dev \
    	    libsdl2-dev
    # server build dependencies
    sudo apt install openjdk-11-jdk # version may be different according to debian's version 
    
  • because I don't install server, so I download pre-built server file from https://github.com/Genymobile/scrcpy/releases/download/v1.9/scrcpy-server-v1.9.jar ( version may be different). copy the downloaded jar file to a folder, source code folder of srccpy may be a good choice
  • go to scrcpy folder

    meson x --buildtype release --strip -Db_lto=true \
          -Dprebuilt_server=/path/to/scrcpy-server.jar
    cd x
    ninja
    sudo ninja install
    

Connect to phone ( 2 )

  • open android mobile phone (Android 5.0 or newer device) to enable adb debugging. On some devices you may also need to enable an additional "USB debugging (Security settings)" option to be able to control the Android device from your desktop computer.
  • connect via USB
    • connect phone to PC with USB (be aware of using official USB cable but not charge only cable )
    • phone may ask whether to trust the PC or not, it would be good to click "always trust" if the PC is personal and will be often used to connect the phone
    • under PC's command line, simply "scrcpy" to start using scrcpy
  • connect via wifi (make sure to connect the device to the same Wi-Fi as PC)
    • under PC's command line

      adb tcpip 5555 # 5555 is default port number, one can speicify different port number as like
      add connect phone_ip:5555 # to confirm phone's IP in Settings-About phone-Status, 5555 is default port number could be ignored
      scrcpy # run scrcpy as usual 
      
  • uninstall

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

Usual usage

  • for fast connection scrcpy can specify connection speed, default is 2Mbps. Use "-b 64M" may be a good idea

    scrcpy --bit-rate 2M
    scrcpy -b 2M  # short version, 
    
  • some useful shortcuts

    shortcuts action
    C-h back to HOME
    C-o off the screen
    C-p on the screen
    C-b Back
    C-g resize Window to 1:1
    C-s App switch
    C-c/C-p copy/paste between phone and PC

Comments

comments powered by Disqus