Android ADB工具-截图和录制视频(五)

Android ADB工具-截图和录制视频(五)

标签(空格分隔): Android ADB


7. 截图和录制视

命令 功能
adb shell screencap –p <path/file> 手机截图
adb shell screenrecord [options] 屏幕录像
  • 屏幕录像命名传入參数说明
C:UsersAdministrator>adb shell screenrecord --help
Usage: screenrecord [options] <filename>

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 megabits per second.  Default 4Mbps.
--time-limit TIME
    Set the maximum recording time, in seconds.  Default / maximum is 180.
--rotate
    Rotate the output 90 degrees.
--verbose
    Display interesting information on stdout.
--help
    Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached.
  • –size WIDTH * HEIGHT : 输入的分辨率。默认是设备屏幕的显示分辨率
  • –bit-rate RATE: 设置视频比特率,默认是4mbps
  • –time-limit TIME: 设置视频的录时(单位:S),默认是180S
  • –rotate : 设置视频旋转90度
  • 终止录制: CTRL + C

手机截图

截图到手机sdcard
将screen.png复制到桌面s

>C:UsersAdministrator>adb shell screencap -p /sdcard/screen.png
>C:UsersAdministrator>adb pull /sdcard/screen.png C:UsersAdministratorDesktop
>4841 KB/s (292531 bytes in 0.059s)

屏幕录像

此命令在Android4.4以上才干够使用

C:UsersAdministrator>adb shell screenrecord /sdcard/s1.mp4

输入此命令后命令会卡在页中,此时已经開始录像了,你能够滑动手机,操作

//開始屏幕录像
C:UsersAdministrator>adb shell screenrecord /sdcard/s1.mp4
^C
//任意操作手机。。。

//拷贝录像到电脑桌面查看
C:UsersAdministrator>adb pull /sdcard/s1.mp4 C:UsersAdministratorDesktop
3394 KB/s (3531759 bytes in 1.016s)

录制320*480尺寸的视频

注意:尺寸使用英文字母x。不是*

C:UsersAdministrator>adb shell screenrecord --size 320*480 /mnt/sdcard/s2.mp4
Invalid size '320*480', must be width x height

C:UsersAdministrator>adb shell screenrecord --size 320x480 /mnt/sdcard/s2.mp4
原文地址:https://www.cnblogs.com/mfmdaoyou/p/6912487.html