Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture the screen as fast as possible through adb? [duplicate]

Tags:

android

adb

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?

like image 601
Robot Dreamer Avatar asked Dec 21 '12 03:12

Robot Dreamer


People also ask

How do I take a screenshot using adb?

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

What is adb exec out?

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.


2 Answers

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

like image 52
steveha Avatar answered Sep 24 '22 01:09

steveha


You could use:

$ adb exec-out screencap -p > test.png 

update

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 

update sep 2021

Using take-screenshot from CulebraTester2 you can achieve a higher frame rate

./take-screenshot   🌄 Image in file:///tmp/culebra.zSSYZ6VG.png  
like image 32
Diego Torres Milano Avatar answered Sep 24 '22 01:09

Diego Torres Milano