
本文教大家如何录制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可以列出所有可用的命令。
tomchen$ ./adb shell screenrecord --helpUsage: screenrecord [options] <filename>Records the device"s display to a .mp4 file.Options:--size WIDTHxHEIGHTSet the video size, e.g. "1280x720". Default is the device"s maindisplay resolution (if supported), 1280x720 if not. For best results,use a size supported by the AVC encoder.--bit-rate RATESet the video bit rate, in megabits per second. Default 4Mbps.--time-limit TIMESet the maximum recording time, in seconds. Default / maximum is 180.--rotateRotate the output 90 degrees.--verboseDisplay interesting information on stdout.--helpShow this message.Recording continues until Ctrl-C is hit or the time limit is reached.tomchen$ pwd/Applications/sdk/platform-tools可以用--size指定视频分辨率的大小,--bit-rate指定比特率的大小。一般我们不需要设置,用默认的就行了。
tomchen$ ./adb shell screenrecord /sdcard/example.mp4然后就可以录制的,默认时间是180s ,一般不需要这么长,录制完之后我们ctrl+c提前结束就行。
adb push <local> <remote> 将电脑上的文件复制到手机(通常是 sd 卡)adb pull <remote> <local> 将手机上的文件复制到电脑示例:
tomchen$ ./adb pull /sdcard/example.mp4 ~/Documents/8786 KB/s (9449246 bytes in 1.050s)Android studio 自带录制功能

点击Start Recording就开始录制了,会弹出录制时间框

录完之后点击Stop Recording,停止录制。

最后会提示录制视频的保存位置,自己选个文件夹保存。
Android Studio 也提供了截屏功能,就在录制按钮的上方

点击截屏会弹出手机当前的操作界面,还可以用Reload刷新手机界面。

视频转gif
这儿方法也有很多
本文讲解Android 下如何录制App操作生成Gif动态图的方法,希望对大家的学习有所帮助。