一、adb shell screencap 截屏指令
通过adb工具里的help 指令查看screncap指令的用法:
C:\Users>adb shell screencap -help
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
将截屏保存到手机内存中再导入到电脑中:
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png D:/1
二、adb shell screenrecord 录屏指令
首先通过help指令查看screenrecord指令的用法
C:\Users\>adb shell screenrecord --help
Usage: screenrecord [options] <filename>
Android screenrecord v1.2. Records the device's display to a .mp4 file.
Options:
--size WIDTHxHEIGHT
Set the video size, e.g. "1280x720". Default is the device's main
display resolution (if supported), 1280x720 if not. For best results,
use a size supported by the AVC encoder.
--bit-rate RATE
Set the video bit rate, in bits per second. Value may be specified as
bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 4Mbps.
--bugreport
Add additional information, such as a timestamp overlay, that is helpful
in videos captured to illustrate bugs.
--time-limit TIME
Set the maximum recording time, in seconds. Default / maximum is 180.
--verbose
Display interesting information on stdout.
--help
Show this message.
Recording continues until Ctrl-C is hit or the time limit is reached.
录屏:--
time
-limit
adb shell screenrecord --time-limit 200 /sdcard/record.mp4
若不指定则默认录屏时间为180s
adb shell screenrecord /sdcard/record.mp4
screenrecord命令支持Android4.4(API level 19)以上,支持的视频格式为mp4
录屏视频分辨率大小:--size
adb shell screenrecord --size 1280*720 /sdcard/record.mp4
默认是设备的主显示分辨率,否则为1280x720。
指定视频的比特率: --bit-rate
adb shell screenrecord --bit-rate 5000000 /sdcard/record.mp4
指定录屏视频比特率为5Mpbs,如果不指定则默认为4Mbps