Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screenshot of the Nexus One from adb?

My goal is to be able to type a one word command and get a screenshot from a rooted Nexus One attached by USB.

So far, I can get the framebuffer which I believe is a 32bit xRGB888 raw image by pulling it like this:

adb pull /dev/graphics/fb0 fb0 

From there though, I'm having a hard time getting it converted to a png. I'm trying with ffmpeg like this:

ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb8888 -s 480x800 -i fb0 -f image2 -vcodec png image.png 

That creates a lovely purple image that has parts that vaguely resemble the screen, but it's by no means a clean screenshot.

like image 567
Marcus Avatar asked May 10 '10 23:05

Marcus


People also ask

How do I take a screenshot using ADB?

Use the ADB option exec-out instead of shell in the screencap command. For example, adb exec-out screencap screenshot. png. This command will store the screenshot direct on your PC in the folder where you have started the command.


2 Answers

A vastly easier solution for ICS is to use the following from the command line

adb shell /system/bin/screencap -p /sdcard/screenshot.png adb pull /sdcard/screenshot.png screenshot.png 

This'll save the screenshot.png file in the current directory.

Tested on a Samsung Galaxy SII & SII running 4.0.3.

like image 174
Ben Clayton Avatar answered Sep 27 '22 19:09

Ben Clayton


Actually, there is another very simple ability to grab screenshot from your android device: write simple script 1.script like this:

# Imports the monkeyrunner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice  # Connects to the current device, returning a MonkeyDevice object device = MonkeyRunner.waitForConnection()  # Takes a screenshot result = device.takeSnapshot()  # Writes the screenshot to a file result.writeToFile('1.png','png') 

and call monkeyrunner 1.script.

like image 22
Andrey Starodubtsev Avatar answered Sep 27 '22 21:09

Andrey Starodubtsev