Android手机如何录制屏幕及转GIF

来源:互联网 发布:淘宝vivo智能手机 编辑:程序博客网 时间:2024/05/17 01:15

     有时候我们需要录制Android手机的屏幕,比如写了一个Demo应用,需要发布到博客和微博上。

    目前只有4.4以上版本的真机(不支持虚拟机)支持频幕视频录制功能。

    你需要更新adt版本(如果你当前adt版本不能升级platform tools到V19或以上),然后升级platform tools。

    本以为会在ddms看到相应的UI按钮帮助我录屏,最后还是乖乖的开了shell。

    控制台进入adt的安装目录,找到sdk/platform-tools/,使用shell命令:

    adb shell screenrecord /sdcard/recording.mp4  
     后者为输出的目录和文件名,可以自定义,另外有参数可供选择:

  • --help : Displays a usage summary.帮助菜单。
  • --size : Sets the video size, for example: 1280x720. The default value is the device's main display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device's Advanced Video Coding (AVC) encoder.设置视频大小。
  • --bit-rate : Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps. You can increase the bit rate to improve video quality or lower it for smaller movie files. The following example sets the recording bit rate to 6Mbps: screenrecord --bit-rate 6000000 /sdcard/demo.mp4.设置视频比特率。
  • --time-limit : Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).设置录制时间,单位是秒,最长180秒即3分钟。
  • --rotate : Rotates the output 90 degrees. This feature is experimental.90度旋转输出结果。
  • --verbose : Displays log information on command line screen. If you do not set this option, the utility does not display any information while running.录制时输出一些信息包括尺寸大小,比特率等。 

     录制命令

adb shell screenrecord /sdcard/test.mp4

     视频保存目录可以自己指定,如上面的/sdcard/test.mp4,
     命令执行后会一直录制180s,按下ctrl+c可以提前结束录制

   设定视频分辨率

    对于高分辨率的手机,录制的视频很大,我们分享又不需要这么大的
   我们可以设置录制的视频分辨率

  adb shell screenrecord --size 848x480 /sdcard/test.mp4

    设定视频比特率

       默认比特率是4M/s,为了分享方便,我们可以调低比特率为2M

  adb shell screenrecord --bit-rate 2000000 /sdcard/test.mp4

    获取视频文件

       使用adb pull 即可把手机SD卡中视频获取到本地

  adb pull /sdcard/test.mp4 .

    转GIF文件

       在Windows下有个不错的软件Free Video to GIF Converter可以把mp4转换成GIF。
      转换时还可以删除不需要的帧,这点真得很不错。

1 0
原创粉丝点击