3

I want to take a screenshot of my rooted samsung device using command line. I have a constraint of time, I shouldn't exceed 2 s. So my question is how can i take a screenshot using command line.

  • This answer is good: https://stackoverflow.com/a/31401447/211292 – ThomasW Feb 06 '18 at 07:58
  • Possible duplicate of [Screenshot of the Nexus One from adb?](https://stackoverflow.com/questions/2807070/screenshot-of-the-nexus-one-from-adb) – Alex P. Aug 06 '18 at 16:14

1 Answers1

6

The following commands can be used to take a screenshot.

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

Source


Update: After some research I've noticed a similar question that has an answer that might help you:

If the slow part is raw to png conversion (time adb shell screencap -p /sdcard/x.png is considerably slower than time adb shell screencap /sdcard/nonpng.raw, as I have it in games)

This shell script by max_plenert is a better example:

adb shell screencap /sdcard/mytmp/rock.raw
adb pull /sdcard/mytmp/rock.raw
adb shell rm /sdcard/mytmp/rock.raw

// remove the header
tail -c +13 rock.raw > rock.rgba

// extract width height and pixelformat:
hexdump -e '/4 "%d"' -s 0 -n 4 rock.raw
hexdump -e '/4 "%d"' -s 4 -n 4 rock.raw
hexdump -e '/4 "%d"' -s 8 -n 4 rock.raw

convert -size 480x800 -depth 8 rock.rgba rock.png

Source

Community
  • 1
  • 1
Oceans
  • 3,445
  • 2
  • 17
  • 38