0%

adb命令之录屏screenrecord

命令格式:

1
2
3
4
5
# 录制视频
$ adb shell screenrecord [参数] /sdcard/demo.mp4

# 导出视频
$ adb pull /sdcard/demo.mp4

示例:

1
2
3
$ adb shell screenrecord --size 720x1280 --time-limit 180 /sdcard/capture.mp4
$ adb shell screenrecord --time-limit 180 /sdcard/demo.mp4
$ adb shell screenrecord --verbose --time-limit 180 /sdcard/demo.mp4

具体参数介绍(–help)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ 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 20Mbps.
--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.

1. 指定录屏尺寸

1
2
--size WIDTHxHEIGHT
# 如 --size 720x1280

注意

一些异形屏手机,如水滴屏、U型屏等,不是标准的1080P(1080x1920)或者720P(720x1280)的屏幕尺寸,如不指定size进行录屏,则默认使用其非标准尺寸进行录屏,而一般AVC编码器不支持该种异形尺寸,导致录屏失败。

示例如下:

1
2
3
4
5
6
$ adb shell screenrecord --verbose /sdcard/capture.mp4
Main display is 1080x2340 @56.39fps (orientation=0)
Configuring recorder for 1080x2340 video/avc at 20.00Mbps
Content area is 1080x2340 at offset x=0 y=0
Encoder failed (err=-38)
Stopping encoder and muxer

2. 比特率设置

1
2
--bit-rate RATE
# 默认20Mbps

3. 添加例如时间戳等附加信息

1
2
--bugreport
# 目的方便调试

4. 设置录屏时长

1
--time-limit TIME

单位为秒,如 –time-limit 180 即为录制3分钟。

5. 打印详细输出信息

1
--verbose

如上面异形屏录制失败的信息

6. 显示帮助信息

1
--help
坚持原创技术分享,您的支持将鼓励我继续创作!