查看adb截图帮助命令
> adb shell screenrecord -h 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 /system/bin/screencap -p /sdcard/screenshot.png(保存到SDCard) adb pull /sdcard/screenshot.png d:/screenshot.png(保存到电脑)
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.
录制命令
adb shell screenrecord /sdcard/test.mp4
视频保存目录可以自己指定,如上面的/sdcard/test.mp4,命令执行后会一直录制180s,按下ctrl+c可以提前结束录制
设定视频分辨率
对于高分辨率的手机,录制的视频很大,我们分享又不需要这么大的
我们可以设置录制的视频分辨率
adb shell screenrecord --size 848*480 /sdcard/test.mp4
设定视频比特率
默认比特率是4M/s,为了分享方便,我们可以调低比特率为2M
adb shell screenrecord --bit-rate 2000000 /sdcard/test.mp4
获取视频文件
使用adb pull 即可把手机SD卡中视频获取到本地
adb pull /sdcard/test.mp4 .
转GIF文件
在Windows下有个不错的软件Free Video to GIF Converter可以把mp4转换成GIF。
转换时还可以删除不需要的帧,这点真得很不错。
Mac上可以使用gifrocket进行转换。
还有一些在线的转换工具可以使用,但是都会打上水印。