目标
- 在Android手机上进行操作
- 最终生成操作的gif图
限制
方案
- adb shell screenrecord /sdcard/demo.mp4 –size 1080×1920 –time-limit 10
- adb pull /sdcard/demo.mp4 .
- ffmpeg -i demo.mp4 small.gif
安装
脚本
脚本地址
#/bin/bash
function createGif() {
if [ -e $mp4_name ]; then
rm -rf $mp4_name
fi
echo "record the screen"
adb shell screenrecord $mp4_name --size 1080x1920 --time-limit 10
echo "download the screen file"
adb pull $mp4_name ./d.mp4
echo "convert the screen file to gif file"
ffmpeg -i d.mp4 $gif_name
rm -rf d.mp4
open $gif_name
}
if [ $# == 1 ]; then
gif_name=$1
mp4_name="/sdcard/d.mp4"
echo "create gif file ${gif_name}"
createGif
else
echo "./ a.sh a.gif"
fi
参考