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.
Asked
Active
Viewed 8,633 times
3
-
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 Answers
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
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 thantime 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
-
-
-
size of my phone: 1080x1920, using this command I can't change the size of the screenshot? – Sabrine Moumni Oct 01 '15 at 09:30
-
I meant the size of the file. And what time are you measuring, the time it takes to pull or the time to actually take it? – Oceans Oct 01 '15 at 09:31
-
the size of the file is 1,96 Mo , i'm measuring the time to take the screenshot – Sabrine Moumni Oct 01 '15 at 09:33
-
-
the command convert is unkown on my phone , I should do everything on phone not on pc, even the screenshot I can keep it on phone – Sabrine Moumni Oct 01 '15 at 09:52
-
I test the command ffmpeg, on my pc it gives a screenshot with wrong colors , on my phone it doesn't work at all – Sabrine Moumni Oct 01 '15 at 10:10
-
where is the file that I should add to my phone, so that it can know the command ffmpeg, I think it's a sh file – Sabrine Moumni Oct 01 '15 at 13:18