使用 ADB 捕获图片并录制视频

| 选择喜欢的代码风格  

adb 屏幕截图


连接设备:

adb connect 192.168.56.80:5555
....

$ adb devices
List of devices attached
192.168.56.80:5555      device

adb 屏幕截图


adb shell screencap -p /sdcard/screenshot.png

拉取到本地

adb pull /sdcard/screenshot.png

您可以选择将以下内容添加到 .bash_profile 文件中

alias capture="adb shell screencap -p > $@"

那么以后,就可以直接用 capture myfile.jpg 完成工作了

adb 录屏


要录屏,您不能立即将文件录制到计算机上。您需要先将其存储在安卓手机 OR 安卓电视的 SD 卡中,如下所示:

adb shell screenrecord /sdcard/video.mp4

#可以加入相应的参数,比如 --verbose、size、-bit-rate、time-limit 等..
adb shell screenrecord --verbose ---time-limit=120 /sdcard/video.mp4

完成录制后,输入 Ctrl+C

adb pull /sdcard/video.mp4

然后您可以从 sdcard 中删除文件

adb shell rm /sdcard/video.mp4

adb 使用过程中注意的几个地方


adb 连接设备的时候,有多个的情况下:

$ adb devices
List of devices attached
192.168.56.80:5555      device
192.168.56.83:5555      device

这个时候,可以使用 adb -s 192.168.56.80 shell ... ?。

adb shell 扩展阅读:




发表评论