码迷,mamicode.com
首页 > 移动开发 > 详细

Android系统如何录制屏幕(录制成mp4格式)

时间:2014-11-30 13:59:42      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:android   blog   http   io   ar   os   使用   sp   for   

 

      不管是教学,还是为了演示,如果能将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需要后面跟一个mp4文件名。最简单的形式如下:

screenrecord /sdcard/game.mp4    

但要注意,mp4要写入的目录必须是可写的。

当然,可以跟很多选项,常用的就是--size(尺寸)、--bit-rate(比特率)和--time-limit(录制最大时间)

尺寸默认是当前手机屏幕分辨率、比特率是默认4Mbps、录制时间默认是3分钟(180秒)

screenrecord --time-limit 100    /sdcard/game.mp4 

      上面的命令最大可录制100秒的视频。如果想中途停止录制,可按Ctrl C,终止录制,game.mp4仍然会生成,但只会录制从开始录制到按Ctrl-C这段时间的视频。下图是我录制的20秒射击游戏的效果图。完整视频可在下面的地址下载。

bubuko.com,布布扣

 

录制视频下载

Android系统如何录制屏幕(录制成mp4格式)

标签:android   blog   http   io   ar   os   使用   sp   for   

原文地址:http://www.cnblogs.com/nokiaguy/p/4132999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!