每天一个adb命令:screen 命令详解

screen命令分为截屏screencap命令及录制视频screenrecord命令。

screencap命令:
sage: 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.

截屏保存到sd卡:

adb shell screencap -p /sdcard/screen.png

搜了下,截屏可以直接保存到电脑上,

adb shell screencap -p | sed 's/\r$//' > screen.png

但是运行后,打开生成的png文件一直是损坏状态,待研究。

但是先迂回用:先保存到手机,再pull到PC的方式。

adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png ~/Desktop/

或者perl可以直接保存到pc:

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
screenrecord命令

前提:
仅支持Android4.4(API level 19)以上
仅支持视频格式: mp4

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 4Mbps.
--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.

将录制视频保存到sdcard,默认录制时间180s,按下command+c结束录制。

adb shell screenrecord sdcard/record.mp4

录制10s,分辨率为1280*720的视频:

adb shell screenrecord  --time-limit 10 --size 1280x720 /sdcard/demo.mp4

注意:尺寸使用英文字母x,不是*,否则会提示“Invalid size ‘1280*720’, must be width x height”

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值