0

Use-case

Mirror Android Screen to PC using USB

Potential (Native) Implementation Approaches

  1. Using Android Open-Source, modify screenrecord for your needs and re-install on your Android device using ADB
  2. Use well known native API such as OpenGL/OpenMAX to capture screen

Discussion

Approach #1 will certainly work ( under the shell account ), however, each time the Android OS is updated, the custom code will need to get updated to keep up with OS changes, with approach #2 the API stay fixed and there is no need to worry about OS changes, the question is whether it is possible to implement Mirroring solely using OpenGL/OpenMAX ?

Questions

Having the above said, what would be the best approach to mirror the android screen via USB ?

NadavRub
  • 2,520
  • 27
  • 63

2 Answers2

5

The screenrecord that ships with Android 5.0 "Lollipop" can send raw H.264 over ADB. The command line looks like:

adb shell screenrecord --output-format=h264 - | <player>

A few details are on the bigflake page. I've used it to mirror the screen onto a Linux workstation, but unfortunately I didn't save the VLC/mplayer command lines. Some player suggestions are here.

You can try to do uncompressed frames (--output-format=raw-frames), but at decent frame rates that easily overwhelms the ADB connection, even if the screen is tiny.

Source code is here.

Community
  • 1
  • 1
fadden
  • 51,356
  • 5
  • 116
  • 166
  • 1
    I have the screenrecord thing working, the gotcha with this approach is that in order to go around the 3min duration limitation you need to pathch the code and re-compile, and this, impose a maintanance cost each time the os is updated, a solution using conventional apis would be optimal/what i am looking for – NadavRub Dec 15 '14 at 05:58
0

As suggested by fadden, I have ended up patching through sreeenrecord disabling the time limitation and adding some code of my own ( enabling ADB over USB routing ), it works, BUT, req maintanance each time the OS is updated, I wish there would have been a way for using the Android Java framework as an ADB Shell Tool as this would considerably reduce the amount of un-documented buttons I am pressing...

Community
  • 1
  • 1
NadavRub
  • 2,520
  • 27
  • 63
  • 1
    Could you post a code example of getting this running? I am having a devil of a time combining the sparse knowledge of this to make mine work. – Kristopher Dec 11 '15 at 21:56