Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture the screen using /dev/graphics/fb0 (Android)

Tags:

android

driver

How to capture the Android device screen content using /dev/graphics/fb0 and how to make it an image file using the collected data from frame buffer. I know for this it requires the device to be rooted and I am ok with that.

Thanks in advance,

like image 964
manju Avatar asked Jan 11 '11 06:01

manju


3 Answers

If you are not sure about the format of your device frame buffer you can iterate ffmpeg supported formats as follows:

for fmt in $(ffmpeg -pix_fmts|cut -d " " -f 2); do ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt $fmt -s 320x480 -i fb0 -f image2 -vcodec png /tmp/image-$fmt.png; done

The outcome thumbnails are also kind of artistic.

like image 58
Ville Ilvonen Avatar answered Sep 23 '22 09:09

Ville Ilvonen


This should work:

adb pull /dev/graphics/fb0 fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 320x480 -i fb0 -f image2 -vcodec png image.png
like image 13
nebkat Avatar answered Oct 15 '22 01:10

nebkat


If you have the root privilege.

  1. copy data from fb0 to another file, e.g.

    cat fb0 > tmp
    
  2. At this point, you still can't open the new file. because the data structure of the the file cannot met any image file format. So what you need is to decode it. In that file, every two bytes describe a pixel. the higher 5 bites represent the red color, the lower 5bites represent the blue color and the rest middle 6 bites are green. you can use the info above to build a BMP and any other visible file.

like image 5
Andrew Avatar answered Oct 15 '22 00:10

Andrew