Screen Mirroring Android device to Desktop

So it comes a time when your neck starts to hurt and your fingers look down on your device and tapping onto the screen.

But what can you do?

For a while, I was also troubled with this question and truth to be told, while i was investigating how to create a low budget good software for automated testing I crossed with few possible solutions:

  • Implement a client that is deployed on device and server that receives its output.

( This idea I got while i was testing devices in Samsung Test Lab  )

  • Do through adb screenshots each second and see what is happening on the device

But these solutions could only provide visual output of the device not also being able to control it.

Then I dug around the web a little bit and found a solution made by Genymotion  company.

It's called scrcpy shot for (Screen Copy ).

https://149366088.v2.pressablecdn.com/wp-content/uploads/2019/06/scrcpy-mirror-android.jpg

It is cross platform solution that gives one option to control your device with Desktop PC or Laptop through USB or WiFi.

It 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)

Really great program. Now what I wanted to achieve is that I don’t do commands always and have it incorporated through my tool :)

So In order to invoke scrcpy you need to start it as a new process and send device information.

Down fall, is that if you want to record a screen with it, you need also that send on startup, and when you want to “finish” recording you need to turn off completely scrcpy process :/

So in the end I was able to integrate running scrcpy on both modes USB / WiFi through my testing device software :)

All what is needed to be done is:

  • Enable USB debugging on device
  • Make sure you run adb
  • If you want to run adb wirelessly then run adb with tcpip command
  • Get device network address:
  • If you don't want to do it by going to Settings-> About -> Network there is an adb command that you can use:
  • adb shell ip -f inet addr show wlan0
  • Run scrcpy process with informations:
  • scrcpy.exe -s device -r screen_record.mp4

And that's it, with this utility you can control your device through your pc and watch action on big screen :D

Comments

    Leave a comment