Using ADB to capture the screen

user2513924 picture user2513924 · Jan 4, 2015 · Viewed 103.9k times · Source

I'm trying to get a screenshot of the phone screen as fast as possible. Currently, I am doing:

adb shell screencap -p /sdcard/screencap.png && adb pull /sdcard/screencap.png         

However it is too slow and takes up to 3 seconds. Is there any better way to do this? I intend to use this function with an unrooted phone.

Also what are the different arguments I can use for screencap?

Thanks.

EDIT (extra information): I intend to use this method to be able to get a live feed of the screen onto my pc. The current method works however it is too slow. I can't use adb shell screenrecord because I won't be able to access the video file while it is being recorded.

Answer

Diego Plentz picture Diego Plentz · May 12, 2016

To save to a file on Windows, OSX and Linux

adb exec-out screencap -p > screen.png

To copy to clipboard on Linux use

adb exec-out screencap -p | xclip -t image/png