跳至主要内容

adb视频录制命令screenrecord

Android视频录制命令screenrecord

你要知道:

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

一些限制

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

开始录制命令:

adb shell screenrecord /sdcard/demo.mp4
说明:录制手机屏幕,视频格式为mp4,存放到手机sd卡里,默认录制时间为180s

限制录制时间:

参数: --time-limit
adb shell screenrecord  --time-limit 10 /sdcard/demo.mp4
说明:限制视频录制时间为10s,如果不限制,默认180s

指定视频分辨率大小:

参数: --size
adb shell screenrecord --size 1280*720 /sdcard/demo.mp4
说明:录制视频,分辨率为1280*720,如果不指定默认使用手机的分辨率,为获得最佳效果,请使用设备上的高级视频编码(AVC)支持的大小

指定视频的比特率

参数: --bit-rate
adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4
说明:指定视频的比特率为6Mbps,如果不指定,默认为4Mbps. 你可以增加比特率以提高视频质量或为了让文件更小而降低比特率

在命令行显示log

参数: --verbose
bixiaopeng@bixiaopeng wirelessqa$ adb shell screenrecord --time-limit 10 --verbose /sdcard/demo.mp4
Main display is 1080x1920 @60.00fps (orientation=0)
Configuring recorder for 1080x1920 video at 4.00Mbps
Content area is 1080x1920 at offset x=0 y=0
Time limit reached
Encoder stopping; recorded 96 frames in 10 seconds
Stopping encoder and muxer
Executing: /system/bin/am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/demo.mp4

Broadcasting: Intent { act=android.intent.action.MEDIA_SCANNER_SCAN_FILE dat=file:///sdcard/demo.mp4 }
Broadcast completed: result=0

旋转90度

参数: --rotate
说明:此功能为实验性的,好不好用不知道

查看帮助命令

参数: --help
bixiaopeng@bixiaopeng ~$ 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 pull /sdcard/demo.mp4
说明:导出视频到当前目录
www.wirelessqa.me

评论

此博客中的热门博文

go url encoding

func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

IP地址的分类及应用

IP地址的分类及应用   IP地址可以分为A、B、C、D、E五类。通常,使用的IP都属于A、B、C三类,而D、E网则用于特殊用途,并且不使用和A、B、C类网相同的规律。所以,下面只谈谈A、B、C三类IP地址的使用。   在A、B、C三类IP地址中,使用了不同长度的网络部分和主机部分来表示地址,在如下表示中可以看到三类IP地址的网络部分数字决定了它默认的子网掩参院,所以清楚地知晓网络部分和主机部分的数字范围是十分有必要的。   对于专业的网络管理人员来说,需要知晓以下知识:   A类地址   适合于超大型的网络。我们知道,IP地址分为w.x.y.z四个组(即四个字节),其中的w是其网络部分,w值的可用范围是1~126,所以可以提供126个A类的网络数。而主机部分是x.y.z三个字节(1Byte=8bit),因此24位可以支持(2的24立方)-2=16777216-2=16777214台主机。   B类地址   适合于大、中型网络,其网络部分占用w.x 两个字节,由于w的可用范围是128-191,因此可以提供(191-128+1)x256=16384个网络数。而主机部分共占用y.z两个字节,因此每个网络可以支持(2的16立方)-2=65536-2=65534主机。   C类地址   适合办公及家庭小型号网络,其网络部分占用wxy三个字节,由于w的可用范围是192-223,所以它可以提供(223-192+1)x256x256=2067152个C类网络。而主机部分只占用z一个字节,所以每一个网络只能使用(2的8立方)-2=254台主机。   IP地址中的困惑   现在来解释一下上述计算中的一些可能会让读者们困惑的地方:   困惑1:127是一个保留的地址,它表示本机地址,主要用于测试网卡与驱动程序是否正常运行。   困惑2:为什么要减2?这是因为每一个网络的第1个是代表网络本身,最后一上IP地址代表广播地址,这两个地址不能直接被主机使用,所以要减去2能得到实际上可以使用的主机台数。以192.168.1.0这个C类网络为例,192.168.1.0就是网络本身,而主机部分侧为192.168.1.1---192.168.1.254,192.168.1.255是保留广播用途的。   困惑3:为什么要乘以256?这是因为W、X、Y、Z四组的每一组数量最大为...