Android 自带录屏命令 screenrecord 的使用

本文介绍了Android系统内置的screenrecord命令,用于录制屏幕。详细讲解了如何通过ADB使用screenrecord,包括设置录制时间、视频分辨率、比特率等参数,并提到了一些使用限制,如不支持屏幕旋转和录制声音。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发现 Android 系统自带录屏命令 screenrecord,其可执行文件位于:/system/bin/ ,源码位于:frameworks/av/cmds/screenrecord

  • screenrecord是一个shell命令
  • 支持Android4.4(API level 19)以上
  • 支持视频格式: mp4

通过 screenrecod --help 帮助命令查看提示选项:

D:\log>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. 录制屏幕

adb shell screenrecord /sdcard/screenrecord.mp4

说明:录制手机屏幕,mp4 封装格式,并保存到sdcard,默认录制时间为180s,录制期间可以通过 Ctrl+C 结束录屏。

2. 指定录制时间,参数 --time-limit

adb shell screenrecord --time-limit 20 /sdcard/screenrecord.mp4

说明:--time-limit 设置最大录制时间长度,默认 180 秒,录制期间可以通过 Ctrl+C 结束录屏。

3. 指定视频分辨率大小,参数 --size

adb shell screenrecord --size 1280*720 /sdcard/screenrecord.mp4

 说明:录制视频,设定分辨率为1280*720,如果不指定,默认使用手机的分辨率。

4. 指定视频的比特率, 参数  --bit-rate

adb shell screenrecord --bit-rate 6000000 /sdcard/screenrecord.mp4

说明:指定视频的比特率为6Mbps,如果不指定,默认为4Mbps。你可以增加比特率以提高视频质量或为了让文件更小而降低比特率。

5. 旋转90度,参数: --rotate

adb shell screenrecord --rotate /sdcard/screenrecord.mp4

6. 打印Log:

adb shell screenrecord --time-limit 10 --verbose /sdcard/screenrecord.mp4

7. 查看录屏进程pid:

adb shell "ps -A | grep screenrecord"

USER	PID  PPID     VSZ	RSS				WCHAN		ADDR	    S	NAME
root	6430	1	2182300	15068	futex_wait_queue_me	72a5c743b0	S	screenrecord

8. 导出视频:

adb pull /sdcard/screenrecord.mp4 D:/

一些限制:

  • 某些设备可能无法直接录制,原因是分辨率太高,如果遇到此类问题,请试着指定较低的分辨率
  • 不支持录制过程中屏幕旋转,如果录制过程中旋转,有可能画面被切断
  • 录制视频的时候声音不会被录下来

 

推荐阅读:

改进安卓自带screenrecord录屏程序,支持录屏/横竖屏识别/实时推送raw h264.

https://blog.csdn.net/huang_165/article/details/102228886

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值