Recently, I wrote a PC client which can display and control my android phone screen in real-time using adb. I use the monkey to control the device and it works fine. The problem is how to grab the phone screen and display it smoothly.
The first solution I have come up with is to continually grab the framebuffer
through adb
(like DDMS's screen capture function). Now when I do it, the performance is quite unacceptable. The frame rate captured from framebuffer
is as low as 5 per second (the frame size is 800 * 480). My program looks like its hiccuping when I slide on the phone.
My program is written in java using ddmslib
to grab framebuffer
.
add:
I found it much slow to encoding the raw framebuffer
data into .png
format, otherwise this will be a fast way to transmit a compress raw image.
How can I improve the speed of capturing the screen to a smooth level?
Hold down the Shift key on your keyboard, right-click anywhere blank in the adb folder, and select Open command window here. Head to Settings > System > Developer options on your Android device, and enable USB debugging. (You might need to enable Developer options first.)
adb exec-out "<command>" Run command on Android and capture its unfiltered binary output (stdout) – undocumented feature. adb exec-in "<command>" Run command on Android and feed the unfiltered console input (stdin) – undocumented feature.
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
Source:
http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
You could use:
$ adb exec-out screencap -p > test.png
Android 11 introduces debug over wifi and speeds the things a bit
$ time adb exec-out screencap -p > test.png real 0m0.661s user 0m0.050s sys 0m0.066s
Using take-screenshot from CulebraTester2 you can achieve a higher frame rate
./take-screenshot 🌄 Image in file:///tmp/culebra.zSSYZ6VG.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With