Android下录制App操作生成Gif动态图的全过程

2019-12-10 19:15:14刘景俊
这篇文章主要为大家分享了Android下录制App操作生成Gif动态图的全过程,感兴趣的小伙伴们可以参考一下  

Android App开发完了,自然希望录个gif做个展示。视频也可以做展示,但是需要上传到优酷、土豆等等,而且本来就十几秒的App演示操作过程,视频网站的广告就要一分钟,没有gif轻量简单省流量。

下图是我录制的一个短信轰炸机应用的效果图:

Android下录制App操作生成Gif动态图的全过程

本文教大家如何录制gif,,具体内容如下

思路

生成gif的思路是两步

1、把App操作过程录制成视频
2、根据视频转换成Gif

目前网上录制GIf的思路也基本都是分为这2步,不知道有没有更好的方法,一步就生成gif动态的?

利用adb 录制屏幕

在Android sdk下面有一些很有用的工具,adb位于platform-tools文件夹,开发者用它在设备上安装启动应用。早期的sdk版本中,adb位于tools文件夹中。

在终端(linux或者mac os)或者命令提示符(windows)键入

adb help all

可以列出所有可用的命令。

注意,如果经常使用adb工具,建立把sdk的文件夹路径添加到PATH环境变量中。不加入到环境变量中,每次启动adb都需要cd到platform-tools文件夹的位置。
我们录制屏幕利用 adb shell screenrecord命令,还可以使用adb shell screenshot进行截屏。下面是使用说明

 

tomchen$ ./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.

tomchen$ pwd
/Applications/sdk/platform-tools