不管是教学,还是为了演示,如果能将Android手机(或平板)的屏幕录制成视频文件,那是一件非常酷的事(iOS8已经提供了这一功能,能通过OS X直接在Mac上录制iPad、iPhone的屏幕,windows没试过,不知可不可以)。不过以前的方法都是通过截屏录制的,效果极差。幸好 Android4.4以上版本提供了这一功能。但无法在手机上直接启动,需要通过adb使用命令行启动。

大家可以进入shell。或干脆直接用adb shell执行命令。该命令是screenrecord,可以输入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 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.

你要知道:
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
说明:导出视频到当前目录

参考链接:http://blog.csdn.net/wirelessqa/article/details/22725581

Android视频录制命令screenrecord的更多相关文章

  1. Android截图命令screencap与视频录制命令screenrecord

    Android截图命令screencap 查看帮助命令 bixiaopeng@bixiaopeng ~$ adb shell screencap -v screencap: invalid optio ...

  2. 利用FFmpeg玩转Android视频录制与压缩(二)<转>

    转载出处:http://blog.csdn.net/mabeijianxi/article/details/72983362 预热 时光荏苒,光阴如梭,离上一次吹牛逼已经过去了两三个月,身边很多人的女 ...

  3. android视频录制、另一部手机实时观看方案

    最近调研android视频录制.另一部手机实时观看,大致有以下几种思路. 1. android手机充当服务器,使用NanoHTTPD充当服务器,另一部手机或者pc通过输入http://手机的ip:80 ...

  4. Android视频录制从不入门到入门系列教程(一)————简介

    一.WHY Android SDK提供了MediaRecorder帮助开发者进行视频的录制,不过这个类很鸡肋,实际项目中应该很少用到它,最大的原因我觉得莫过于其输出的视频分辨率太有限了,满足不了项目的 ...

  5. Android视频录制从不入门到入门系列教程(三)————视频方向

    运行Android视频录制从不入门到入门系列教程(二)————显示视频图像中的Demo后,我们应该能发现视频的方向是错误的. 由于Android中,Camera给我们的视频图片的原始方向是下图这个样子 ...

  6. Android拓展系列(9)--Android视频录制screenrecord命令

    在Android4.4 Kitkat上集成了一个比较好用的视频录制功能.参考:http://forums.androidcentral.com/android-4-4-kitkat/329674-ho ...

  7. android 视频录制 混淆打包 之native层 异常的解决

    原文地址:http://www.cnblogs.com/linguanh/    (滑至文章末,直接看解决方法) 问题起因: 前5天,因为项目里面有个类似 仿微信 视频录制的功能, 先是上网找了个 开 ...

  8. Android视频录制从不入门到入门系列教程(四)————Camera Parameter

    Camera提供了一个叫做setParameters的方法帮助开发者设置相机的相关参数. 通过Camera的getParameters方法可以获取到当前为相机设置的相关参数. 下面简单介绍下,视频录制 ...

  9. 我的Android进阶之旅------>Android视频录制小例子

    ============================首先看看官网上关于视频捕捉的介绍================================ Capturing videos Video ...

随机推荐

  1. 057、macvlan 网络隔离和连通(2019-03-26 周二)

    参考https://www.cnblogs.com/CloudMan6/p/7400580.html   在上一节中,两个host上四个容器的网络信息如下,然后进行网络连通性测试,可见通vlan的容器 ...

  2. 学习go语言编程系列之helloworld

    1. 下载https://golang.org/dl/ # Go语言官网地址,在国内下载太慢,甚至都无法访问.通过如下地址下载:https://golangtc.com/download. 2. 安装 ...

  3. Excel公式使用

    IF语句: 想要给F16自动求值,可以利用IF语句,如下: 语句: 同时,还需要设置B27的单元格格式为“常规”

  4. Win下安装nvm

    nvm 是 windows 下切换 node 版本的管理工具,mac 下可以使用 TJ 写的 n . 1.https://github.com/coreybutler/nvm-windows/rele ...

  5. [C++]最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583)

    Question 例题3-5 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583) 如果x+x的各个数字之和得到y,就是说x是y的生成元.给出n( ...

  6. luogu P3767 膜法

    传送门 这题如果没有删除操作,可以直接使用可持久化并查集 注意到这种可持久化的依赖关系(是这样说的把)是一棵树,然后对于一个点,自己的操作会影响自己的那棵子树,并且如果是删除操作,就会使得一个子树没有 ...

  7. netty的解码器和粘包拆包

    Tcp是一个流的协议,一个完整的包可能会被Tcp拆成多个包进行发送,也可能把一个小的包封装成一个大的数据包发送,这就是所谓的粘包和拆包问题 粘包.拆包出现的原因: 在流传输中出现,UDP不会出现粘包, ...

  8. mysql 修改文件记录:

    增:  insert  t1(id, name) values(1, "alex"), (2, "wusir"), (3, "dabing" ...

  9. Jquery简单应用-1.8.3

    Jquery属于什么? javascript的一个库 一个.js文件 用什么用? 可以提高javascript的编程效率 使用流程 用一个html<script type='text/javas ...

  10. linux atoi

    atoi 只能针对字符串为数字, 对字符串为十六进制.八进制的不能进行转化