不管是教学,还是为了演示,如果能将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. PHP7 学习笔记(十二)Stream 函数详解

    官方:http://php.net/manual/zh/ref.stream.php Stream_*系列函数 PHP中对流的描述如下:每一种流都实现了一个包装器(wrapper),包装器包含一些额外 ...

  2. floyd求最小环

    ;i<=n;i++) ;j<=n;j++) g[i][j]=g[j][i]=dis[i][j]=dis[j][i]=inf; ;i<=m;i++){ int u,v,w;scanf( ...

  3. l类与对象课后作业

    java 的初始化规律 执行类成员定义时指定的默认值或类的初始化块,到底执行哪一个要看哪一个“排在前面”. 执行类的构造函数. 类的初始化块不接收任何的参数,而且只要一创建类的对象,它们就会被执行.因 ...

  4. alexnet- tensorflow

    alexnet 在 imagenet上夺冠是卷积神经网络如今这么火热的起点. 虽然卷积神经网络很早就被提出来,但是由于计算能力和各方面原因,没有得到关注. alexnet 为什么能取得这么好的成绩,它 ...

  5. tensorflow/core/kernels/conv_ops.cc:659] check failed: stream->parent()->getc

    tensorflow版本与cudnn版本不对应,如tensorflow-gpu==1.1.0,cudnn==6.0 升级tensorflow-gpu到更高版本

  6. pycharm活动模板

    1.复制模板内容 2.文件设置: 点击+号:

  7. localStorage用法

    引用:https://www.cnblogs.com/st-leslie/p/5617130.html const STORAGE_KEY = 'todos-vuejs'; export defaul ...

  8. mybatis的两个核心对象SqlSessionFactory和SqlSession对象

    mybatis的两个核心对象SqlSessionFactory和SqlSession对象 参见:https://www.cnblogs.com/wxdestiny/p/9743686.html

  9. Coursera, Deep Learning 1, Neural Networks and Deep Learning - week1, Introduction to deep learning

    整个deep learing 系列课程主要包括哪些内容 Intro to Deep learning

  10. flask处理cookie

    一 什么是cookie 什么是cookie?如果单单从数据结构的角度来说,它可以被理解成用来保存数据的一个dictionary,由一组组键值对组成.如果从作用上来说,我们知道Http协议是一种无状态的 ...