Skip to content

Instantly share code, notes, and snippets.

@tsengvn
Created December 5, 2018 07:53
Show Gist options
  • Save tsengvn/99f2b7c3730a0d4e6b5c496eb9cb8931 to your computer and use it in GitHub Desktop.
Save tsengvn/99f2b7c3730a0d4e6b5c496eb9cb8931 to your computer and use it in GitHub Desktop.
Record android device and convert to gif script
pullAndConvert() {
rm record.gif >/dev/null 2>&1
echo "Pull record..."
adb pull /sdcard/record.mp4 ./record.mp4 >/dev/null 2>&1
echo "Converting..."
ffmpeg -i record.mp4 -filter:v "setpts=1.0*PTS" -vf scale=360:-1 record.gif -loglevel panic
rm record.mp4
echo "Output: $PWD/record.gif"
echo "Done"
}
adb shell screenrecord /sdcard/record.mp4 & export pid=$!
read -n 1 -p "Press 's' to stop recroding: " input
echo ""
if [ "$input" = "s" ]
then
echo "Stop recording"
disown $pid
kill -9 $pid >/dev/null 2>&1
sleep 1
pullAndConvert
else
kill -9 $pid >/dev/null 2>&1
echo "Wrong input, just kill"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment